attempt to merge

This commit is contained in:
Benjamin Bohard 2020-09-10 12:15:23 +02:00
parent 231394b1cd
commit 619b74c815
1 changed files with 44 additions and 34 deletions

View File

@ -81,43 +81,53 @@ def git_integration(func):
author = repo.default_signature author = repo.default_signature
committer = author committer = author
repo.checkout('refs/heads/master') if func.__name__ == 'init':
index = repo.index comment = 'Initialisation de la formation'
for fp in master_add_paths: elif func.__name__ == 'update':
index.add(fp) comment = 'Construction de la formation'
index.write() elif func.__name__ == 'outline':
tree = index.write_tree() comment = 'Mise à jour du programme'
master_ref = repo.references['refs/heads/master'] else:
parents = [master_ref.peel().hex] comment = 'Travail sur la formation'
repo.create_commit('refs/heads/master',
author,
committer,
'comment',
tree,
parents)
repo.checkout(f'refs/heads/{branch_name}') if master_add_paths:
for fp in branch_add_paths: repo.checkout('refs/heads/master')
index.add(fp) index = repo.index
index.write() for fp in master_add_paths:
tree = index.write_tree() index.add(fp)
branch_ref = repo.references[f'refs/heads/{branch_name}'] index.write()
parents = [branch_ref.peel().hex] tree = index.write_tree()
repo.create_commit(f'refs/heads/{branch_name}', master_ref = repo.references['refs/heads/master']
author, parents = [master_ref.peel().hex]
committer, master_head = repo.create_commit('refs/heads/master',
'comment', author,
tree, committer,
parents) comment,
tree,
parents)
else:
master_head = repo.revparse_single('refs/heads/master')
basket = repo.branches.get(branch_name) if branch_add_paths:
cherry = repo.lookup_branch('refs/heads/master').target repo.checkout(f'refs/heads/{branch_name}')
base = repo.merge_base(cherry, basket.target) index = repo.index
base_tree = cherry.parents[0].tree for fp in branch_add_paths:
index.add(fp)
index.write()
tree = index.write_tree()
branch_ref = repo.references[f'refs/heads/{branch_name}']
parents = [branch_ref.peel().hex]
repo.create_commit(f'refs/heads/{branch_name}',
author,
committer,
comment,
tree,
parents)
if master_head not in repo.walk(branch_ref.target):
repo.merge(master_head)
tree = repo.index.write_tree()
merge_commit = repo.create_commit('HEAD', author, committer, 'Merge master into xelatex/*', tree, [repo.head.target, master_head])
index = repo.merge_trees(base_tree, basket, cherry)
tree_id = index.write_tree(repo)
repo.create_commit(basket.name, author, committer, 'bof', tree_id, [basket.target])
return inner return inner