git integration
This commit is contained in:
parent
3563d18c0c
commit
72d42ec54c
|
@ -68,16 +68,45 @@ def git_integration(func):
|
|||
master_ref = repo.references['refs/heads/master']
|
||||
commit = master_ref.peel()
|
||||
repo.branches.local.create(branch_name, commit)
|
||||
|
||||
# état du dépôt, si il n’est pas propre, sortir
|
||||
# checkout sur la branche master
|
||||
# création d’une branche spécifique pour le document à partir de la branche master
|
||||
# création des fichiers
|
||||
func(args)
|
||||
if repo: # à transformer en decorateur éventuellement
|
||||
print('add et commit')
|
||||
# ajout tout le contenu hors presentations dans la branche master
|
||||
# ajout de tout le contenu de presentations dans la branche spécifique
|
||||
if repo:
|
||||
repo_status = repo.status()
|
||||
to_add_status = [pygit2.GIT_STATUS_WT_NEW,
|
||||
pygit2.GIT_STATUS_WT_MODIFIED]
|
||||
branch_add_paths = [fp for fp in repo_status
|
||||
if fp.startswith(f'presentations/') and repo_status[fp] in to_add_status]
|
||||
master_add_paths = [fp for fp in repo_status
|
||||
if (fp.startswith('content/') or fp.startswith('slides/')) and repo_status[fp] in to_add_status]
|
||||
|
||||
author = pygit2.Signature(repo.config['user.name'], repo.config['user.email'])
|
||||
committer = author
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
return inner
|
||||
|
||||
def main():
|
||||
|
@ -105,7 +134,7 @@ def main():
|
|||
if args.directory:
|
||||
root = root + re.sub(r'[\w-]+/?', '../', args.directory)
|
||||
|
||||
name = 'master.tex'
|
||||
name = 'diaporama.tex'
|
||||
|
||||
title = args.title
|
||||
if not title:
|
||||
|
|
Loading…
Reference in New Issue