Repo status overview (#1017)

Co-authored-by: guenthgr <guenther.grill@frauscher.com>
This commit is contained in:
Günther Grill 2023-01-13 06:43:03 +01:00 committed by GitHub
parent e29dcbb023
commit 04eb5c04e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 65 additions and 9 deletions

View file

@ -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.

View file

@ -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

View file

@ -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

View file

@ -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>
.

View file

@ -119,6 +119,10 @@ $ git summary --dedup-by-email
<p> This option can not be used together with <code>--dedup-by-email</code> or <code>--no-merges</code>.</p>
<p> --oneline</p>
<p> Summarizes the repository within one line. Some information like the authors cannot be displayed in this mode.</p>
<h2 id="EXAMPLES">EXAMPLES</h2>
<p> Outputs a repo summary:</p>
@ -179,9 +183,15 @@ authors :
...
</code></pre>
<p> Oneline summary</p>
<pre><code>$ git summary --oneline
git-extras / age: 5 days / last active: 5 days ago / active on 799 days / commits: 1692 / uncommitted: 4
</code></pre>
<h2 id="AUTHOR">AUTHOR</h2>
<p>Written by Tj Holowaychuk &lt;<a href="&#x6d;&#x61;&#105;&#108;&#x74;&#111;&#x3a;&#116;&#x6a;&#x40;&#118;&#x69;&#x73;&#105;&#111;&#110;&#45;&#x6d;&#101;&#100;&#x69;&#x61;&#x2e;&#x63;&#x61;" data-bare-link="true">&#116;&#x6a;&#x40;&#118;&#x69;&#x73;&#x69;&#111;&#110;&#x2d;&#x6d;&#101;&#100;&#x69;&#x61;&#x2e;&#x63;&#x61;</a>&gt;</p>
<p>Written by Tj Holowaychuk &lt;<a href="&#x6d;&#97;&#x69;&#108;&#x74;&#111;&#x3a;&#116;&#x6a;&#64;&#118;&#105;&#115;&#105;&#x6f;&#x6e;&#x2d;&#109;&#x65;&#100;&#x69;&#97;&#46;&#x63;&#97;" data-bare-link="true">&#x74;&#x6a;&#x40;&#118;&#105;&#x73;&#105;&#111;&#110;&#45;&#x6d;&#x65;&#x64;&#105;&#97;&#x2e;&#99;&#97;</a>&gt;</p>
<h2 id="REPORTING-BUGS">REPORTING BUGS</h2>
@ -194,7 +204,7 @@ authors :
<ol class='man-decor man-foot man foot'>
<li class='tl'></li>
<li class='tc'>December 2022</li>
<li class='tc'>January 2023</li>
<li class='tr'>git-summary(1)</li>
</ol>

View file

@ -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 &lt;<tj@vision-media.ca>&gt;