libgit2 / libgit2/libgit2sharp

View Incoming Commits from a Pre-Receive Hook

未关闭
#1,977 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
C#
星标
3.5k
派生
925
PR 合并指标
30 天内没有已合并 PR

描述

I have developed a pre-receive hook using C#/.NET and used libgit2sharp to retrieve the commits that are being pushed from the client. When I access the Repository.Commits, I only see the old commits not the ones that are being pushed.

I tried using a bash script to implement the hook and execute git rev-list $rev_old..$rev_new and it works and I can see the commits.

So, I'm wondering why does the bash script work and the C#/.NET executable does not given that both executables are executing on the same working directory that Git assigns to the hook.

P.S. I'm using BitBucket Server on-premise deployment - it shouldn't matter I think because the hook works at the Git level not BitBucket

Reproduction steps
  1. Create a .NET 6.0 Console application and add a reference to libgit2sharp.
  2. Write code to obtain the commits between the old ref and the new ref as provided by Git.
  3. Build and configure the hook on the Git repository directory.
  4. Use a Git client to push commits to the server.
Expected behavior

The commits coming from the client should be seen when the Repository.Commits is enumerated.

Actual behavior

Only the commits before the push are returned not the incoming commits.

Version of LibGit2Sharp (release number or SHA1)

0.26.2

Operating system(s) tested; .NET runtime tested

Ubuntu 18.04 and .NET 6.0

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,在 Ubuntu 18.04 和 .NET 6.0 上使用 libgit2sharp 0.26.2 重现 pre-receive hook,将 Repository.Commits 与 Git 提供的旧 ref 值和新 ref 值进行比较。阅读 hook 的 ref 参数以及 Repository.Commits 的行为;当可以观察到传入的 commits,或已记录该限制和正确用法时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp, git
领域
tooling
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。