简体   繁体   English

如何别名git flow hotfix finish [current_hotfix_branch]

[英]how to alias git flow hotfix finish [current_hotfix_branch]

git flow only allows one hotfix branch at any one time. git flow在任何时候都只允许一个修补程序分支。 So rather than typing: 所以不要输入:

git flow hotfix finish hotfix_branch

I'dl like to create an alias that uses the only existing hotfix branch name. 我想创建一个使用唯一现有修补程序分支名称的别名。 Something like the following pseudocode: 像下面的伪代码:

[alias]
  fix-done = flow hotfix finish `git_fetch_branch_beginning_with_hotfix`

Can anyone help? 有人可以帮忙吗? Thanks. 谢谢。

Update: I'm using zsh. 更新:我正在使用zsh。

This function is more or less extracted from git-flow 's source code: 这个函数或多或少是从git-flow的源代码中提取的:

finish_current_hotfix_branch ()
{
  local hotfix_prefix=$(git config --get gitflow.prefix.hotfix)
  local hotfix_branches=$(echo "$(git branch --no-color | sed 's/^[* ] //')" | grep "^$hotfix_prefix")
  local first_branch=$(echo ${hotfix_branches} | head -n1)
  first_branch=${first_branch#$hotfix_prefix}
  git flow hotfix finish "$first_branch"
}

Update 更新

It seems like you have to put the entire function in your alias. 看起来你必须把整个函数放在你的别名中。 Not nice, but works: 不好,但有效:

[alias]
  fix-done ="!_() { p=$(git config --get gitflow.prefix.hotfix); b=$(echo \"$(git branch --no-color | sed 's/^[* ] //')\" | grep \"^$p\"); f=$(echo ${b} | head -n1); f=${f#$p}; git flow hotfix finish \"$f\"; }; _"

这是另一种做git flow hotfix完成别名的方法:

hf = "!_() { b=$(git rev-parse --abbrev-ref HEAD) && git co master && git pl && git co develop && git pl && git co $b && git rebase master && h=$(echo $b | sed 's/hotfix\\///g') && git flow hotfix finish -m 'new_tag' $h && git co master && git ps && git co develop && git ps && git ps --tags && git poo $b && git br -D $b;  }; _"

If you run git flow AVH Edition you can just do 如果你运行git flow AVH Edition就可以了

$ git flow finish

when you are on the branch you want to finish. 当你在分支机构时,你想完成。 This works for hotfix, release, feature and bugfix. 这适用于修补程序,发行版,功能和错误修复。

To check if you run git flow AVH Edition 检查你是否运行git flow AVH Edition

$ git flow version
x.xx.x (AVH Edition)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM