'Failed to create commit: current tip is not the first parent' for basic commit
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 1.7k
- Forks
- 408
- Merge moyen
- 2 j 57 min
- PR mergées (30 j)
- 7
Description
I am trying to do something relatively simple which is just add and commit file changes to an existing repository as i would through the command line. The one complicating caveat is i am calling the code to do this from inside a submodule, however everything seems to be okay until the commit part.
In the folder above the code/submodule folder i have another which is the main git repo and which also has a folder of data i wish to monitor and commit changes of.
The code is
data_repo = pygit2.Repository('../')
index = data_repo.index
index.add_all(pathspecs=["tables/"]) # Because of the data repo path we are already in that repo local path so all paths relative to that
index.write()
tree = index.write_tree()
modified_tables = [ x for x in data_repo.status().keys() if 'tables' in x]
author = pygit2.Signature('Alice Author', 'alice@authors.tld')
committer = pygit2.Signature('GitRateWatcher', 'me@internet.com')
msg = f"GitRateWatcher commit on {datetime.datetime.today().date()} modified tables: {', '.join(modified_tables)}"
oid = data_repo.create_commit('refs/heads/master', author, committer, msg, tree, [] )
data_repo.head.set_target(oid)
However when I try this i get
_pygit2.GitError: failed to create commit: current tip is not the first parent
if i remove the 'refs/heads/master' part it works but it basically does a rebase and wipes all previous stuff which is no good either. What am I missing?
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par l’appel data_repo.create_commit montré et la cible refs/heads/master, puis examinez le rapport entre sa liste de parents et la pointe actuelle du dépôt. Reproduisez la disposition du sous-module et du dépôt parent décrite dans l’issue et vérifiez qu’un nouveau commit conserve l’historique existant au lieu de le rebaser. C’est terminé lorsque le commit réussit tout en conservant l’historique antérieur de la branche.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- git, python
- Domaine
- devtools
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100