libgit2 / libgit2/libgit2sharp

Exception while trying to retrieve last commit from shallow repo

未關閉
#1,493 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
C#
星號
3.5k
分支
925
PR 合併指標
30 天內沒有已合併 PR

描述

In my custom MSBuild task code tries to get last commit hash to put it into one of assembly attributes. Task works very well with repositories cloned with full depth but fails with the following error in repositories with limited depth created with command git clone --depth xx - where xx is number of last commits to clone.

/home/travis/build/DjvuNet/DjvuNet/DjvuNetBuild.Core.targets(20,5): error :
 LibGit2Sharp.NotFoundException: 
object not found - no match for id (d53e5a7166904479d42953bd0f91264f5ace1f6d)
[/home/travis/build/DjvuNet/DjvuNet/DjvuNet.NETStandard2.0/DjvuNet.NETStandard2.0.csproj] 

Code used to retrieve commit data is as follows:

    Repository repo = new Repository(RepoRoot);
    var commits = repo.Commits;
    var commit = commits.FirstOrDefault();

Seems to be libgit2sharp implementation bug as git fully supports enumeration of limited depth repos.

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從報告中顯示的 Repository.Commits 入口點開始,使用透過 git clone --depth xx 建立的儲存庫重現此失敗。將淺層儲存庫的列舉結果與回報的 NotFoundException 進行比較,然後確認擷取第一個 commit 時能夠成功,且不會出現缺少物件的錯誤。Issue 中未指定特定的測試檔案。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
csharp, git
領域
devtools
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。