libgit2 / libgit2/libgit2sharp
View Incoming Commits from a Pre-Receive Hook
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 3.5k
- Forks
- 925
- PR merge metrics
- No merged PRs in 30d
Description
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
- Create a .NET 6.0 Console application and add a reference to
libgit2sharp. - Write code to obtain the commits between the old ref and the new ref as provided by Git.
- Build and configure the hook on the Git repository directory.
- 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the pre-receive hook with libgit2sharp 0.26.2 on Ubuntu 18.04 and .NET 6.0, comparing Repository.Commits with the old and new ref values supplied by Git. Read the hook’s ref arguments and the Repository.Commits behavior; done means the incoming commits are observable or the limitation and correct usage are documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, git
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100