The feature is:only user in the approved-list can push code to a special branch. I use Atlassian Bitbucket as Gitserver. In the hook pre-update. I need to figure out the user who is pushing the code.
for example:
git add 1
git commit
git cherry-pick 2
git cherry-pick 3
git push
There are 3 commits in a push, The author is different,the commiter is same. In pre-update, refer to the atlassian developer api
com.atlassian.bitbucket.hook.repository.RepositoryHookRequest;
com.atlassian.bitbucket.repository.RefChange;
I can only get the author of every commit.In this example,I can get 3 different user names. some code bellow:
Collection<RefChange> refChanges = request.getRefChanges();
for (RefChange refChange : refChanges) {
List<Commit> commits = CommitSvc.getCommitsBetweenFromAndTo(refChangeNew, repo, false);
for (Commit commit : commits) {
String username = commit.getAuthor().getName()
}
}
So, Does anyone know how to get the user who are pushing the code? Is there an api or git-command support this function?
This feature is like "Prevent changes without a pull request, except by:". How to achieve this function in my scripts. Or may I set the permission in bitbucket through api? Because it will take a long time and need many times of executions if we do it manually.For example:
PROA/repo1 PROA/repo2 PROA/repo3 for user1.
PROA/repo2 PROA/repo4 for user2.