From 04eb5c04e60f17dd0685e57cc2767c8f40229084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Grill?= Date: Fri, 13 Jan 2023 06:43:03 +0100 Subject: [PATCH] Repo status overview (#1017) Co-authored-by: guenthgr --- Commands.md | 7 +++++++ bin/git-bulk | 3 ++- bin/git-summary | 19 ++++++++++++++----- man/git-summary.1 | 22 +++++++++++++++++++++- man/git-summary.html | 14 ++++++++++++-- man/git-summary.md | 9 +++++++++ 6 files changed, 65 insertions(+), 9 deletions(-) diff --git a/Commands.md b/Commands.md index 614f9d7..c16350b 100644 --- a/Commands.md +++ b/Commands.md @@ -221,6 +221,13 @@ project : git-extras The `--line` option can also take a path, which will print a filtered summary for that folder or file. +The option `--oneline` tries to put as much summary information of the repo into a single output line + +```bash +$ git summary --oneline +git-extras / age: 5 days / last active: 5 days ago / active on 799 days / commits: 1692 / uncommitted: 4 +``` + ## git effort Displays "effort" statistics, currently just the number of commits per file, showing highlighting where the most activity is. The "active days" column is the total number of days which contributed modifications to this file. diff --git a/bin/git-bulk b/bin/git-bulk index 4b5f62f..040ed8e 100755 --- a/bin/git-bulk +++ b/bin/git-bulk @@ -70,7 +70,8 @@ function guardedExecution () { # atomic git command execution with log function atomicExecution () { - echo 1>&2 "${bldred}->${reset} executing ${inverse}git $gitcommand${reset}" && git "$@" + [ "${quiet?}" != "true" ] && echo 1>&2 "${bldred}->${reset} executing ${inverse}git $gitcommand${reset}" + git "$@" } # check if the passed command is known as a core git command diff --git a/bin/git-summary b/bin/git-summary index 6916c48..86b0109 100755 --- a/bin/git-summary +++ b/bin/git-summary @@ -6,6 +6,7 @@ cd "$(git root)" || { echo "Can't cd to top level directory";exit 1; } SUMMARY_BY_LINE= DEDUP_BY_EMAIL= MERGES_ARG= +SUMMARY_ONELINE= for arg in "$@"; do case "$arg" in --line) @@ -17,6 +18,9 @@ for arg in "$@"; do --no-merges) MERGES_ARG="--no-merges" ;; + --oneline) + SUMMARY_ONELINE=1 + ;; -*) >&2 echo "unknown argument $arg found" exit 1 @@ -145,7 +149,7 @@ format_authors() { # fetch repository age from oldest commit # repository_age() { - git log --reverse --pretty=oneline --format="%ar" -n 1 | LC_ALL=C sed 's/ago//' + git log --reverse --pretty=oneline --format="%ar" | head -n 1 | LC_ALL=C sed 's/ago//' } # @@ -186,14 +190,19 @@ uncommitted_changes_count() { } # summary -echo -echo " project : $project" - -if [ -n "$SUMMARY_BY_LINE" ]; then +if [ -n "$SUMMARY_BY_LINE" ] && [ -n "$SUMMARY_ONELINE" ]; then + echo "$project / lines: $(line_count "${paths[@]}")" +elif [ -n "$SUMMARY_BY_LINE" ]; then + echo + echo " project : $project" echo " lines : $(line_count "${paths[@]}")" echo " authors :" lines "${paths[@]}" | sort | uniq -c | sort -rn | format_authors +elif [ -n "$SUMMARY_ONELINE" ]; then + echo "$project / age: $(repository_age) / last active: $(last_active) / active on $(active_days $commit) days / commits: $(commit_count $commit) / uncommitted: $(uncommitted_changes_count)" else + echo + echo " project : $project" echo " repo age : $(repository_age)" echo " last active : $(last_active)" # shellcheck disable=SC2086 diff --git a/man/git-summary.1 b/man/git-summary.1 index 5f2ecf4..8dc8049 100644 --- a/man/git-summary.1 +++ b/man/git-summary.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "GIT\-SUMMARY" "1" "December 2022" "" "Git Extras" +.TH "GIT\-SUMMARY" "1" "January 2023" "" "Git Extras" . .SH "NAME" \fBgit\-summary\fR \- Show repository summary @@ -65,6 +65,12 @@ Summarize with lines other than commits\. When \fB\-\-line\fR is specified, the .P This option can not be used together with \fB\-\-dedup\-by\-email\fR or \fB\-\-no\-merges\fR\. . +.P +\-\-oneline +. +.P +Summarizes the repository within one line\. Some information like the authors cannot be displayed in this mode\. +. .SH "EXAMPLES" Outputs a repo summary: . @@ -154,6 +160,20 @@ authors : . .IP "" 0 . +.P +Oneline summary +. +.IP "" 4 +. +.nf + +$ git summary \-\-oneline +git\-extras / age: 5 days / last active: 5 days ago / active on 799 days / commits: 1692 / uncommitted: 4 +. +.fi +. +.IP "" 0 +. .SH "AUTHOR" Written by Tj Holowaychuk <\fItj@vision\-media\.ca\fR> . diff --git a/man/git-summary.html b/man/git-summary.html index 6e488f8..0888916 100644 --- a/man/git-summary.html +++ b/man/git-summary.html @@ -119,6 +119,10 @@ $ git summary --dedup-by-email

This option can not be used together with --dedup-by-email or --no-merges.

+

--oneline

+ +

Summarizes the repository within one line. Some information like the authors cannot be displayed in this mode.

+

EXAMPLES

Outputs a repo summary:

@@ -179,9 +183,15 @@ authors : ... +

Oneline summary

+ +
$ git summary --oneline
+git-extras / age: 5 days  / last active: 5 days ago / active on 799 days / commits: 1692 / uncommitted: 4
+
+

AUTHOR

-

Written by Tj Holowaychuk <tj@vision-media.ca>

+

Written by Tj Holowaychuk <tj@vision-media.ca>

REPORTING BUGS

@@ -194,7 +204,7 @@ authors :
  1. -
  2. December 2022
  3. +
  4. January 2023
  5. git-summary(1)
diff --git a/man/git-summary.md b/man/git-summary.md index cfe6b04..24021fb 100644 --- a/man/git-summary.md +++ b/man/git-summary.md @@ -45,6 +45,10 @@ Shows a summary of the repository or a path within it. This option can not be used together with `--dedup-by-email` or `--no-merges`. + --oneline + + Summarizes the repository within one line. Some information like the authors cannot be displayed in this mode. + ## EXAMPLES Outputs a repo summary: @@ -101,6 +105,11 @@ Shows a summary of the repository or a path within it. authors : ... + Oneline summary + + $ git summary --oneline + git-extras / age: 5 days / last active: 5 days ago / active on 799 days / commits: 1692 / uncommitted: 4 + ## AUTHOR Written by Tj Holowaychuk <>