libgit2 / libgit2/pygit2

Suggestion: better handling of `repo.set_head(pygit2.Commit)`

オープン
#750 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Python
スター
1.7k
フォーク
408
平均マージ
2日 57分
マージ済み PR(30日)
7

説明

I have tried to emulate git checkout --detach <commit> in pygit2, to create detached HEAD checkout, and I did come up with the following rough equivalent (though the following does not uses transactions as git does):

rev = repo.revparse_single(commit_name)
repo.checkout_tree(rev)
repo.set_head(rev.id)

However when I tried to use simply repo.set_head(rev), I got the following error:

TypeError                                 Traceback (most recent call last)
<ipython-input-35-9612528ec0ac> in <module>()
----> 1 repo.set_head(rev)

/usr/lib/python2.7/dist-packages/pygit2/repository.pyc in set_head(self, target)
    293
    294         # if it's a string, then it's a reference name
--> 295         err = C.git_repository_set_head(self._repo, to_bytes(target))
    296         check_error(err)
    297

TypeError: initializer for ctype 'char *' must be a cdata pointer, not _pygit2.Commit

It would be nice if pygit2.Commit object was automatically peeled, but if it is decided to be not good idea, then what it needs is more user-friendly error message than the one above.


pygit2 0.26.0

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

repository.py の traceback にある Repository.set_head から始め、示されている revparse_single、checkout_tree、C.git_repository_set_head のフローを比較します。受け入れ可能なターゲット型について、既存のテストまたはドキュメントを確認します。Commit 入力の動作が確定してカバーされており、引き続きサポートされない場合は明確なエラーメッセージも含まれていれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
git, python
領域
tooling
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。