git - 如何获取使用 Atlassian api 推送代码的用户
问题描述
特点是:只有被批准列表中的用户才能将代码推送到特殊分支。我使用 Atlassian Bitbucket 作为 Gitserver。在钩子预更新中。我需要找出推送代码的用户。
例如:
git add 1
git commit
git cherry-pick 2
git cherry-pick 3
git push
一次推送有 3 个提交,作者不同,提交者相同。在更新前,请参考 atlassian 开发者 api
com.atlassian.bitbucket.hook.repository.RepositoryHookRequest;
com.atlassian.bitbucket.repository.RefChange;
我只能得到每个提交的作者。在这个例子中,我可以得到 3 个不同的用户名。一些代码如下:
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()
}
}
那么,有谁知道如何获取推送代码的用户?是否有 api 或 git-command 支持此功能?
此功能类似于“在没有拉取请求的情况下防止更改,除非:”。如何在我的脚本中实现此功能。或者我可以通过api在bitbucket中设置权限吗?因为如果我们手动执行会花费很长时间并且需要多次执行。例如:
PROA/repo1 PROA/repo2 PROA/repo3 for user1.
PROA/repo2 PROA/repo4 for user2.
解决方案
推荐阅读
- c++ - C++ 类:构造函数的列表初始化变得无用了吗?
- node.js - 类型错误:chatManager.connect(...) 未定义
- etw - 如何使用 C# EventSource 和 ETW 实现连续日志记录?
- autohotkey - 请求支持 CapsLock 密钥代码
- kubernetes - 监控每个命名空间的资源
- php - 使用 WooCommerce 在订单备注中关闭订单状态更新
- android - Appsflyer 崩溃:致命异常:MultipleInstallBroadcastReceiver.java 第 43 行的 java.lang.NoSuchMethodError
- python - 无论如何我可以检查python中字符串的一部分是否在另一个字符串中?(初学者)
- kubernetes - Kubernetes 我可以为一个应用程序使用两台服务器吗?
- go - 如何循环直到 *ipconn.Read() 读取了 go 中发送给它的所有数据