libgit2 / libgit2/pygit2

Consistent interface to get text and bytes

Ouverte
#895 8 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

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

Follow up from #610 #790 and #893

General policy:

  • Do not implement str()
  • To get unicode string use .text
  • In .text use UTF-8 and replace (the rationale for replace is explained in https://github.com/libgit2/pygit2/pull/790#issuecomment-385906316)
  • To get the byte string use .data or .raw (this is to be decided)
  • For attributes the name of the attribute returns text, prefix with raw_ to get bytes. For instance Signature.name and Signature.raw_name
  • Implement the buffer protocol, bytes(..) where appropriate

Open for discussion.

TODO:

  • Replace TreeEntry._name by .raw_name
  • Replace DiffLine.content by .text
  • Inventory all the places where we get bytes, text, or the buffer protocol
  • Settle on .data or .raw
  • Replace DiffLine.raw_content by .data or .raw
  • Replace Object.read_raw() by .data (or .raw), then remove Blob.data (it will inherit from Object)
  • Settle on str() bytes() and the buffer protocol

The case of Oid, what we've now:

  • oid.raw returns the byte string (that's good, unless we decide to settle on .data)
  • str(oid) and oid.hex both return the hex representation, always <str> (bytes in Python 2 and text in Python 3)
  • Oid is the only place where we implement str(...)
  • Object.hex and TreeEntry.hex behave the same, they return always <str>. Apparently these are the only places where we always return <str>.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par examiner les issues liées #610, #790 et #893, puis dressez l’inventaire des interfaces actuelles Oid, Object, TreeEntry et DiffLine décrites ici. Pour considérer le travail terminé, il faut arrêter la convention de nommage et la politique de conversion de text/bytes, puis résoudre les TODOs listés de manière cohérente dans tous les bindings.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
git, python
Domaine
api, backend-api-design, tooling
Type d'issue
Refactorisation
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
20/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.