-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add summary fields #1013
Merged
Merged
Add summary fields #1013
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,6 @@ project=${PWD##*/} | |
# | ||
# get date for the given <commit> | ||
# | ||
|
||
date() { | ||
# the $1 can be empty | ||
# shellcheck disable=SC2086 | ||
|
@@ -62,7 +61,6 @@ date() { | |
# | ||
# get active days for the given <commit> | ||
# | ||
|
||
active_days() { | ||
# shellcheck disable=SC2086 | ||
date $1 | sort -r | uniq | awk ' | ||
|
@@ -74,7 +72,6 @@ active_days() { | |
# | ||
# get the commit total | ||
# | ||
|
||
commit_count() { | ||
# shellcheck disable=SC2086 | ||
git log $MERGES_ARG --oneline $commit | wc -l | tr -d ' ' | ||
|
@@ -83,15 +80,13 @@ commit_count() { | |
# | ||
# total file count | ||
# | ||
|
||
file_count() { | ||
git ls-files | wc -l | tr -d ' ' | ||
} | ||
|
||
# | ||
# remove duplicate authors who belong to the same email address | ||
# | ||
|
||
dedup_by_email() { | ||
# in: | ||
# 27 luo zexuan <[email protected]> | ||
|
@@ -132,7 +127,6 @@ dedup_by_email() { | |
# | ||
# list authors | ||
# | ||
|
||
format_authors() { | ||
# a rare unicode character is used as separator to avoid conflicting with | ||
# author name. However, Linux column utility will escape tab if separator | ||
|
@@ -150,9 +144,15 @@ format_authors() { | |
# | ||
# fetch repository age from oldest commit | ||
# | ||
|
||
repository_age() { | ||
git log --reverse --pretty=oneline --format="%ar" | head -n 1 | LC_ALL=C sed 's/ago//' | ||
git log --reverse --pretty=oneline --format="%ar" -n 1 | LC_ALL=C sed 's/ago//' | ||
} | ||
|
||
# | ||
# fetch repository age of the latest commit | ||
# | ||
last_active() { | ||
git log --pretty=oneline --format="%ar" -n 1 | ||
} | ||
|
||
# | ||
|
@@ -181,27 +181,32 @@ line_count() { | |
lines "$@" | wc -l | ||
} | ||
|
||
# summary | ||
uncommitted_changes_count() { | ||
git status --porcelain | wc -l | ||
} | ||
|
||
# summary | ||
echo | ||
echo " project : $project" | ||
echo " project : $project" | ||
|
||
if [ -n "$SUMMARY_BY_LINE" ]; then | ||
echo " lines : $(line_count "${paths[@]}")" | ||
echo " authors :" | ||
echo " lines : $(line_count "${paths[@]}")" | ||
echo " authors :" | ||
lines "${paths[@]}" | sort | uniq -c | sort -rn | format_authors | ||
else | ||
echo " repo age : $(repository_age)" | ||
echo " repo age : $(repository_age)" | ||
echo " last active : $(last_active)" | ||
# shellcheck disable=SC2086 | ||
echo " active : $(active_days $commit) days" | ||
echo " active on : $(active_days $commit) days" | ||
# shellcheck disable=SC2086 | ||
echo " commits : $(commit_count $commit)" | ||
echo " commits : $(commit_count $commit)" | ||
|
||
# The file count doesn't support passing a git ref so ignore it if a ref is given | ||
if [ "$commit" == "HEAD" ]; then | ||
echo " files : $(file_count)" | ||
echo " files : $(file_count)" | ||
fi | ||
echo " authors : " | ||
echo " uncommitted : $(uncommitted_changes_count)" | ||
echo " authors : " | ||
if [ -n "$DEDUP_BY_EMAIL" ]; then | ||
# the $commit can be empty | ||
# shellcheck disable=SC2086 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 update the md file and generate the doc via https://github.com/tj/git-extras/tree/master/man#how-to-generate-documentation
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.
And also this: https://github.com/tj/git-extras/blob/master/Commands.md#git-summary
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.
:) oh I see. Only the MD file must be manually adapted. When modifiying the x.1 file I already wondered how people can modify this file with all the tags and making no mistake. Thx for pointing this out.
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.
Don't forget the https://github.com/tj/git-extras/blob/master/Commands.md#git-summary
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.
@spacewander Done.