tj / git-extras

GIT utilities -- repo summary, repl, changelog population, author commit percentages and more
MIT License
17.31k stars 1.21k forks source link

add support for rendering branch name to `git-standup` #791

Closed smeijer closed 4 years ago

smeijer commented 4 years ago

git standup shows my last commits. But a (long) list of commits, is not always useful to quickly aggregate my work from last week.

If we would be able to visualize the branch in this list, it would become much more useful.

Maybe even group commits under their branches?

feature/update-issue-templates
64a1426 - update templates (87 seconds ago) <Stephan Meijer>
1e00ba7 - update bug-fix.md (37 minutes ago) <Stephan Meijer>
29ffdbd - update feature.md (41 minutes ago) <Stephan Meijer>
1250ec1 - create enhancement.md (41 minutes ago) <Stephan Meijer>

feature/fix-login-bug
64a1426 - sigh... linter again (11 minutes ago) <Stephan Meijer>
29ffdbd - fix linter (12 minutes ago) <Stephan Meijer>
1e00ba7 - fix import statement (14 minutes ago) <Stephan Meijer>
spacewander commented 4 years ago

The problem to group the commits by branch is, commit doesn't belong to only one branch.

I have noticed you are using feature branch. These commits stay in the feature branch currently, but after they are merged, they will be in at least two branches: the original feature branch and the develop branch. Moreover, any newly created feature branches will also contain them. If the user doesn't even use feature branch, the result could be crazier.

It is hard to figure out how much branches a commit belongs to.

smeijer commented 4 years ago

@spacewander, thanks. Everything you're saying makes sense. And yet, it would still be very helpful. Even when the same commit is being displayed under multiple branches.

Would it otherwise be possible to show branches that you've committed to in the last days instead? So don't list the commits under it? Just the branch names and maybe a timestamp of the last commit?

feature/update-issue-templates (87 seconds ago) <Stephan Meijer>
feature/fix-login-bug (11 minutes ago) <Stephan Meijer>

It's just because, I believe if git standup -a "author" would show me the branches author has worked on, it would be more informative than seeing the various commits sorted at commit date.

Exactly for the purpose of that function standup.

spacewander commented 4 years ago

It is possible to make the output like

feature/update-issue-templates (87 seconds ago) <Stephan Meijer>
feature/fix-login-bug (11 minutes ago) <Stephan Meijer>

I will work on it once I have enough free time.

spacewander commented 4 years ago

@smeijer I have submitted the pull request: https://github.com/tj/git-extras/pull/793.

By iterating all the branches and logging their commits, now we can group the commits by branches like this:

 $ git standup -B -a spacewander -d 7

    git-summary-cleanup
    f788c78 - git-summary: clean up other shellcheck warnings (23 hours ago) <spacewander>
    3e8c3ab - git-summary: fix incorrect active days when commits range is given (23 hours ago) <spacewander>
    ff991ac - git-summary: remove useless result function. (23 hours ago) <spacewander>
    203f5b4 - git-summary: add --dedup-by-email to remove duplicate users (5 days ago) <spacewander>
    master
    203f5b4 - git-summary: add --dedup-by-email to remove duplicate users (5 days ago) <spacewander>

Obviously, the same commit 203f5b4 is appeared both in the feature branch and in the master branch. I think it is OK if the user only wants to recall the changes made several days ago.

Could you try this feature and give us your feedback? You can use the commands below to update it:

git clone https://github.com/spacewander/git-extras -b git-standup-group-by-branch
cd git-extras && make install
smeijer commented 4 years ago

@spacewander, awesome! Works like a charm. 😎 This is exactly what I needed.

Some improvements that could be made

  1. A newline before the branch name
λ git standup -B -a spacewander -d 7

git-standup-group-by-branch
7b9fbc4 - git-standup: add option '-B' to group the commits by branch (2 hours ago) <spacewander>
203f5b4 - git-summary: add --dedup-by-email to remove duplicate users (5 days ago) <spacewander>

master
f788c78 - git-summary: clean up other shellcheck warnings (25 hours ago) <spacewander>
3e8c3ab - git-summary: fix incorrect active days when commits range is given (26 hours ago) <spacewander>
ff991ac - git-summary: remove useless result function. (26 hours ago) <spacewander>
203f5b4 - git-summary: add --dedup-by-email to remove duplicate users (5 days ago) <spacewander>

ls
f788c78 - git-summary: clean up other shellcheck warnings (25 hours ago) <spacewander>
3e8c3ab - git-summary: fix incorrect active days when commits range is given (26 hours ago) <spacewander>
ff991ac - git-summary: remove useless result function. (26 hours ago) <spacewander>
203f5b4 - git-summary: add --dedup-by-email to remove duplicate users (5 days ago) <spacewander>
  1. Would it be possible to support a max number of commits per branch?
λ git standup -B 2 -a spacewander -d 7

git-standup-group-by-branch
7b9fbc4 - git-standup: add option '-B' to group the commits by branch (2 hours ago) <spacewander>
203f5b4 - git-summary: add --dedup-by-email to remove duplicate users (5 days ago) <spacewander>

master
f788c78 - git-summary: clean up other shellcheck warnings (25 hours ago) <spacewander>
3e8c3ab - git-summary: fix incorrect active days when commits range is given (26 hours ago) <spacewander>

ls
f788c78 - git-summary: clean up other shellcheck warnings (25 hours ago) <spacewander>
3e8c3ab - git-summary: fix incorrect active days when commits range is given (26 hours ago) <spacewander>
  1. If 2) is possible, than it also becomes useful without the -a flag, to render all authors. But that deserves a separate ticket I think.

With 2 + 3, it would be very useful for team leads during standup. But also to get a quick feeling of what your colleagues are working on.

spacewander commented 4 years ago

2) git standup displays commits in the given time range. What is your use case for limiting the number of commits? 3) You can use -a all to render all authors.

smeijer commented 4 years ago
  1. To get a quick understanding of what's being worked on by the different team members. With -B the branch name helps me get an understanding. At that moment, I wouldn't need like 20 commits per branch any more.

I just want to get the understanding that John worked on feature/x while Jane was working on feature/y and feature/z.

The limiting would be nice to get a clear and clean overview.

Note that I do mean limiting per branch. So -B 2 can still result in 20 different commits. It would just lists only the 2 most recent ones under each branch name.

  1. Awesome! Thanks.
spacewander commented 4 years ago

@smeijer Just push a new commit to https://github.com/tj/git-extras/pull/793 which adds the feature you'd like.

smeijer commented 4 years ago

Used it this morning before standup, and I love it! Thank you so much.

git standup -B -a all -n 5
spacewander commented 4 years ago

Solved.