【问题标题】:git hooks / pre-receive - how to get all the commit messages on a newly created branch? [duplicate]git hooks / pre-receive - 如何获取新创建的分支上的所有提交消息? [复制]
【发布时间】:2018-04-28 07:29:03
【问题描述】:

我想在新创建的分支上获取所有提交消息(例如使用 git log --format=%s)。假设我有 2 次提交:

abcd - from yesterday
bcde - from today

。使用此代码:

while read old new ref; do
    ....
done

旧的将是 40 个零,新的将是 bcde。在这种情况下如何获取所有提交消息?

用例:

git checkout master
git checkout -b new_branch
some_work
git add; git commit
some_other_work
git add; git commit
git push origin new_branch

.

非常感谢。

【问题讨论】:

    标签: git git-branch githooks


    【解决方案1】:

    好吧,如果 $old 为零,我可以使用它:

    if [ $old = $z40 ]; then
        old=`$(git rev-list --boundary $newrev --not --all | sed -n 's/^-//p'`
    fi
    

    .

    【讨论】:

      【解决方案2】:

      如果我理解得很好,你想要这样的东西:

      while read old new ref; do
          if [[ "${old}" =~ ^0+$ ]]; then
              range="${new}"
          else
              range="${old}..${new}"
          fi
          git log --format=%s "${range}"
      done
      

      【讨论】:

      • 好吧,如果 range 只是 $new,它就不会显示所有的 cmets。
      猜你喜欢
      • 2011-11-02
      • 2017-01-18
      • 2018-11-06
      • 2019-08-14
      • 2021-09-16
      • 1970-01-01
      • 1970-01-01
      • 2012-08-16
      • 2014-10-10
      相关资源
      最近更新 更多