Skip to content

Conversation

@guenhter
Copy link
Contributor

@guenhter guenhter commented Feb 2, 2023

Hi,

I've change the git summary --oneline to git summary --output-style tabular which gives an output like this:

# Repo                        | Age      | Last active  | Active on | Commits | Uncommitted
dev-infrastructure-automation | 8 weeks  | 18 hours ago | 22 days   | 46      | 0

When this is combined with the git bulk command, and some other bash magic, then this result can be achieved:

$ git bulk -q summary --output-style tabular | sed '1b;/^#/d' | column -t -s "|" -o "|" 
Core command "summary" accepted.
# Repo                            | Age                 | Last active          | Active on | Commits | Uncommitted
deno-data-handler-prototype       | 9 weeks             | 13 days ago          | 7 days    | 23      | 0
udp-handler                       | 9 weeks             | 2 weeks ago          | 2 days    | 5       | 0
azure-client                      | 9 weeks             | 2 weeks ago          | 2 days    | 4       | 0
dev-infrastructure-automation     | 8 weeks             | 18 hours ago         | 22 days   | 46      | 0
gitlab-project-settings-corrector | 4 months            | 2 weeks ago          | 2 days    | 3       | 0
free-for-all                      | 2 weeks             | 2 weeks ago          | 1 days    | 2       | 0
realm-initializer                 | 4 months            | 6 days ago           | 8 days    | 29      | 0
gitlab-k8s-cleaner                | 4 months            | 4 months ago         | 2 days    | 7       | 0
ci-docker-images                  | 4 months            | 7 days ago           | 4 days    | 9       | 0
...

The main advantage is, that the redundant header information stays just in the header and not pollutes the single lines any more.

@guenhter
Copy link
Contributor Author

guenhter commented Feb 2, 2023

Closes #1023


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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest keeping the oneline output as another output style.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Now both styles are supported

bin/git-summary Outdated
print_summary_by_line() {
if [ "$OUTPUT_STYLE" == "tabular" ]; then
tabular_headers="# Repo | Lines"
echo -e "$tabular_headers\n$project | $(line_count "${paths[@]}")" | column -t -s "|" -o "|"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When running this, I get:

column: invalid option -- 'o'
usage: column [-txne] [-c columns] [-s sep] [file ...]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, that is weired. What OS and do you use and what version of column do you have. According to https://man7.org/linux/man-pages/man1/column.1.html the -o option is there and on my ubuntu 22.04 it's also working.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

man column show that:

HISTORY
     The column command appeared in 4.3BSD-Reno.

There is not version output option in my column

Copy link
Contributor Author

@guenhter guenhter Feb 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double checked. The BSD column command just doesn't have the -o option. I have to think about this how to solve it because the -o would be quite important to have a separator between columns, else my overall-command can't distinguish the single columns...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got rid of the -o option.

@spacewander
Copy link
Collaborator

Let's merge master to make CI pass.

@guenhter
Copy link
Contributor Author

guenhter commented Feb 9, 2023

Done.

@spacewander spacewander merged commit a008308 into tj:master Feb 12, 2023
vanpipy pushed a commit to vanpipy/git-extras that referenced this pull request Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants