-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Support passing ref to git-commits-since
#1228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,36 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| SINCE="last week" | ||
| test $# -ne 0 && SINCE=$* | ||
| echo "... commits since $SINCE" >&2 | ||
| git log --pretty='%an - %s' --after="@{$SINCE}" | ||
| REF="" | ||
| SINCE="" | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| -r|--ref) | ||
| if [[ -z "$2" ]]; then | ||
| echo "error: option $1 requires an argument" >&2 | ||
| exit 1 | ||
| fi | ||
| REF="$2" | ||
| shift | ||
| shift | ||
| ;; | ||
| *) | ||
| # non-flag args accumulation, e.g. "last " + "week" -> "last week" | ||
| SINCE="${SINCE:+$SINCE }$1" | ||
| shift | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| if [[ -n "$REF" && -n "$SINCE" ]]; then | ||
| echo "error: '--ref <ref>' and '<date>' are mutually exclusive" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| SINCE="${SINCE:-last week}" | ||
|
|
||
| if [[ -n "$REF" ]]; then | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check if "$REF" exist before using it
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean the actual ref or the variable itself? IOW do you want me to first verify that git can resolve the ref before I use it with the
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's fine. |
||
| git log --pretty='%h %an - %s' "$REF..HEAD" | ||
| else | ||
| git log --pretty='%h %an - %s' --after="@{$SINCE}" | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,57 +1,52 @@ | ||
| .\" generated with Ronn/v0.7.3 | ||
| .\" http://github.com/rtomayko/ronn/tree/0.7.3 | ||
| . | ||
| .TH "GIT\-COMMITS\-SINCE" "1" "October 2017" "" "Git Extras" | ||
| . | ||
| .\" generated with Ronn-NG/v0.9.1 | ||
| .\" http://github.com/apjanke/ronn-ng/tree/0.9.1 | ||
| .TH "GIT\-COMMITS\-SINCE" "1" "January 2026" "" "Git Extras" | ||
| .SH "NAME" | ||
| \fBgit\-commits\-since\fR \- Show commit logs since some date | ||
| . | ||
| .SH "SYNOPSIS" | ||
| \fBgit\-commits\-since\fR [<date>] | ||
| . | ||
| .TS | ||
| allbox; | ||
| \fBgit\-commits\-since\fR [\-r \-\-ref <ref>] [<date>] | ||
| .TE | ||
| .SH "DESCRIPTION" | ||
| List of commits since the given \fIdate\fR\. | ||
| . | ||
| List of commits since the given \fIdate\fR or \fIref\fR\. | ||
| .SH "OPTIONS" | ||
| <date> | ||
| . | ||
| .P | ||
| Show commits more recent than \fIdate\fR\. By default, the command shows the commit logs since "last week"\. | ||
| . | ||
| Show commits more recent than <date>\. By default, the command shows the commit logs since "last week"\. | ||
| .P | ||
| \-r, \-\-ref <ref> | ||
| .P | ||
| Show commits since the given ref (tag, branch, or commit)\. When specified, the command uses \fBref\.\.HEAD\fR instead of date\-based filtering\. | ||
| .SH "EXAMPLES" | ||
| It is really flexible and these are only 3 of the options, go ahead give it a try: | ||
| . | ||
| .IP "" 4 | ||
| . | ||
| .nf | ||
|
|
||
| $ git commits\-since yesterday | ||
| \.\.\. commits since yesterday | ||
| nickl\- \- Merge branch upstream master\. | ||
| nickl\- \- Rebase bolshakov with master | ||
| TJ Holowaychuk \- Merge pull request #128 from nickl\-/git\-extras\-html\-hyperlinks | ||
| TJ Holowaychuk \- Merge pull request #129 from nickl\-/develop | ||
| nickl\- \- Fix #127 git\-ignore won\'t add duplicates\. | ||
| aa084d9 TweeKane \- Add global gitignore to git\-ignore output | ||
| 515e94a TJ Holowaychuk \- Merge pull request #128 from nickl\-/git\-extras\-html\-hyperlinks | ||
| 5f86b54 TJ Holowaychuk \- Merge pull request #129 from nickl\-/develop | ||
| 7398d10 nickl\- \- Fix #127 git\-ignore won\'t add duplicates\. | ||
|
|
||
| $ git commits\-since 3 o clock pm | ||
| \.\.\. commits since 3 o clock pm | ||
| nickl\- \- Merge branch upstream master\. | ||
| aa084d9 TweeKane \- Add global gitignore to git\-ignore output | ||
|
|
||
| $ git commits\-since 2 hour ago | ||
| \.\.\. commits since 2 hour ago | ||
| nickl\- \- Merge branch upstream master\. | ||
| TJ Holowaychuk \- Merge pull request #128 from nickl\-/git\-extras\-html\-hyperlinks | ||
| TJ Holowaychuk \- Merge pull request #129 from nickl\-/develop | ||
| . | ||
| aa084d9 TweeKane \- Add global gitignore to git\-ignore output | ||
| 515e94a TJ Holowaychuk \- Merge pull request #128 from nickl\-/git\-extras\-html\-hyperlinks | ||
| 5f86b54 TJ Holowaychuk \- Merge pull request #129 from nickl\-/develop | ||
|
|
||
| $ git commits\-since \-\-ref 7\.4\.0 | ||
| 6ed2643 John Bachir \- ability to specify command when hitting enter (#1223) | ||
| b9bd309 John Bachir \- Improve `git\-repl` prompt (#1224) | ||
| 6f4cf0c johnpyp \- feat: `delete\-branch` multiple unique branch names completions (#1221) | ||
| \|\.\|\.\|\. | ||
| 215382b 罗泽轩 \- Bump version to 7\.5\.0\-dev (#1207) | ||
| .fi | ||
| . | ||
| .IP "" 0 | ||
| . | ||
| .SH "AUTHOR" | ||
| Written by Tj Holowaychuk <\fItj@vision\-media\.ca\fR> | ||
| . | ||
| .SH "REPORTING BUGS" | ||
| <\fIhttps://github\.com/tj/git\-extras/issues\fR> | ||
| . | ||
| .SH "SEE ALSO" | ||
| <\fIhttps://github\.com/tj/git\-extras\fR> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's report an error if both $SINCE and $REF given
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.