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
committer = author
repo.checkout('refs/heads/master')
index = repo.index
for fp in master_add_paths:
index.add(fp)
index.write()
tree = index.write_tree()
master_ref = repo.references['refs/heads/master']
parents = [master_ref.peel().hex]
repo.create_commit('refs/heads/master',
author,
committer,
'comment',
tree,
parents)
if func.__name__ == 'init':
comment = 'Initialisation de la formation'
elif func.__name__ == 'update':
comment = 'Construction de la formation'
elif func.__name__ == 'outline':
comment = 'Mise à jour du programme'
else:
comment = 'Travail sur la formation'
repo.checkout(f'refs/heads/{branch_name}')
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_add_paths:
repo.checkout('refs/heads/master')
index = repo.index
for fp in master_add_paths:
index.add(fp)
index.write()
tree = index.write_tree()
master_ref = repo.references['refs/heads/master']
parents = [master_ref.peel().hex]
master_head = repo.create_commit('refs/heads/master',
author,
committer,
comment,
tree,
parents)
else:
master_head = repo.revparse_single('refs/heads/master')
basket = repo.branches.get(branch_name)
cherry = repo.lookup_branch('refs/heads/master').target
base = repo.merge_base(cherry, basket.target)
base_tree = cherry.parents[0].tree
if branch_add_paths:
repo.checkout(f'refs/heads/{branch_name}')
index = repo.index
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