libgit2 / libgit2/pygit2

Repository.resolve_refish does not return a commit if given annotated tag SHA

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

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

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

説明

The repository.resolve_refish function is meant to return a commit object as the first element of the tuple ( source ).

However, if given a SHA of an annotated tag, it returns a tag object instead, which causes problems downstream.

The SHA of the target commit is available under result.target (see below)

How to reproduce:

Execute the following (clone the pygit2 repo into a temporary dir, create an annotated tag):

import pygit2
from pathlib import Path
import tempfile

repo_dir = tempfile.TemporaryDirectory()
repo_path = Path(repo_dir.name)

repo = pygit2.clone_repository("https://github.com/libgit2/pygit2.git", repo_path)
head_sha = repo.head.peel().id

old = repo.create_tag(
    'test_annotated_tag',
    head_sha,
    pygit2.GIT_OBJ_COMMIT,
    pygit2.Signature('John Doe', 'jdoe@example.com', 12347, 0),
    'message'
)

commit, ref = repo.resolve_refish(str(old))

Then we can investigate the results:

In [2]: commit  # not really a commit!
Out[2]: <pygit2.Object{tag:66986bf4eb1e47c3049f5a146609f0aa7b64757d}>

In [3]: commit.target
Out[3]: e2c0fdbfbd7f84374f8c7a3df256547b7ea99192

In [4]: head_sha
Out[4]: e2c0fdbfbd7f84374f8c7a3df256547b7ea99192

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

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

はじめの一歩

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

調査の方向性

Issue で参照されている resolve_refish の実装がある pygit2/repository.py から始めます。提供されたスクリプトで annotated tag の SHA のケースを再現し、その後、返されたオブジェクトとその target を追跡します。このケースでタプルの最初の要素が commit オブジェクトになり、他の refish 入力では既存の動作が維持されれば完了です。

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

評価

技術スタック
git, python
領域
devtools
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
52/100

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

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