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.
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 theRepository.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 executegit 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
libgit2sharp
.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