Ada*_*kin 9 git github bitbucket
我觉得Bitbucket非常方便的一件事就是当你把一个新的分支推到Bitbucket托管的repo时,它打印出(到终端屏幕)一个你可以点击的URL来创建你刚刚推出的那个分支的PR .例如:
$ git push origin someBranch
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 313 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote:
remote: Create pull request for someBranch:
remote: https://bitbucket.mydomain.com/projects/PRO/repos/someRepo/compare/commits?sourceBranch=refs/heads/someBranch
remote:
To ssh://bitbucket.mydomain.com:7999/pro/somerepo.git
f6718d4..410cbcb someBranch -> someBranch
Run Code Online (Sandbox Code Playgroud)
我发现这比去Bitbucket,导航到回购,找到"创建拉动请求"按钮等节省了大量时间.因此,当我使用在Github上托管的回购时,我想要类似的东西 - 在推出新分支后,让它打印到终端上我可以点击的URL到达Github上的创建PR屏幕.有人知道这样的事吗?
我知道Github有一个带有pull-request
命令的CLI ,但每次都会提示你输入密码非常烦人,TBH我喜欢在实际创建PR之前查看UI中的差异.
Ada*_*kin 10
创建了我自己的本地钩子,可以满足我的需求.将此作为pre-push
钩子添加到repo的本地克隆:
#!/bin/sh
branch=$(git rev-parse --abbrev-ref HEAD)
userRepo=$(git remote -v | grep fetch | awk '{print $2}' | grep "github.com" | cut -d':' -f2 | rev | cut -c5- | rev)
if [ -n "$userRepo" ]
then
echo ""
echo "Create PR at: https://github.com/$userRepo/compare/$branch?expand=1"
echo ""
fi
Run Code Online (Sandbox Code Playgroud)
示例输出:
$ git push origin testouthooks
Create PR at: https://github.com/pzelnip/dotfiles/compare/testouthooks?expand=1
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 284 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To github.com:pzelnip/dotfiles.git
f7c29b8..f6f9347 testouthooks -> testouthooks
Run Code Online (Sandbox Code Playgroud)
然后我可以点击那个在Github的创建拉取请求页面上发出的url,其中我刚刚推送了作为源分支的分支.
这与Bitbucket并不完全相同,因为它在本地运行(Bitbucket在远程运行)因此它不那么智能(例如:即使推送导致遥控器没有变化等,它仍会发出URL) .但它适合我的需要"当我推送到Github回购时,我可以从我的终端窗口点击链接到Github中的创建PR页面".
归档时间: |
|
查看次数: |
1266 次 |
最近记录: |