Repository.create_note() does not accept bytes
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
Hi,
Thank you for pygit2! I'm using it heavily in a project to present all Ubuntu source package history as git repositories.
Any chance Repository.create_note() could be adjusted to accept bytes as well as str? An issue I just hit is when I'm trying to create git notes that contain text that is not UTF-8 encoded. This happened historically in Debian/Ubuntu packaging history and I'd like to represent that in git notes that get created by just "passing through" the unknown encoding. As git doesn't care about the encoding of a note, I think this should work OK.
The relevant code is here: https://github.com/libgit2/pygit2/blob/58da6bb2b958139dab285e183ca6616509960587/src/repository.c#L1677
It looks like this could just be tweaked slightly to also accept a bytes, as it's all being converted into a C-string to hand to git anyway. There might be an edge case to consider when the bytes contains NULs. That might have to be unacceptable, tested for and result in a ValueError. It might also make sense to adjust behaviour everywhere pygit2 accepts a string to hand to git, so I appreciate it's a bit of a rabbit hole.
This isn't essential so I can work around this and don't want to get into testing a patch right now, but I thought it might be worth noting this in your issue tracker (and I can now link to this from my workaround).
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 dans src/repository.c autour de Repository.create_note() à la ligne 1677 et examinez comment le message de la note est converti avant d’être transmis à Git. Le travail est terminé lorsque bytes est accepté au même titre que str pour le contenu de note non UTF-8, avec un comportement défini pour les octets NUL intégrés, par exemple en les rejetant avec ValueError.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- git, python
- Domaine
- devtools
- Type d'issue
- Fonctionnalité
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 48/100