Is it possible to get a list of merges into a branch from the Github website OR API?

后端 未结 3 1880
傲寒
傲寒 2021-01-31 15:14

In our workflow, no \"direct\" commits are made into the master branch. The master branch only receives merges from Pull Requests.

We can think of each merge then as a n

3条回答
  •  闹比i
    闹比i (楼主)
    2021-01-31 15:49

    I use the following script:

    git log --merges --first-parent master \
            --pretty=format:"%h %<(10,trunc)%aN %C(white)%<(15)%ar%Creset %C(red bold)%<(15)%D%Creset %s"
    

    Explaining each argument:

    • --merges: only "merge" commits (more than 1 parent);
    • --first-parent master: only merges applied to master. This removes the entries where someone merged master into their branches;
    • --pretty-format: applies the following formatting:
      • %h: the commit short hash;
      • %<(10,trunc)%aN: author name, truncated at 10 chars;
      • %<(15)%ar: the relative commit time, padded to 15 chars;
      • %<(15)%D: the tag names, also padded to 15 chars;
      • %s: first line of the commit message.

    The result is pretty satisfying:

提交回复
热议问题