├── .gitignore ├── .tito ├── packages │ ├── .readme │ └── git-insight ├── releasers.conf └── tito.props ├── .vscode └── settings.json ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── docs ├── branch-comparison.png ├── critical-files.png ├── demo-add-dels.png ├── demo-git-calendar.png ├── issues.MD ├── new-rpm.md ├── repo-analysis.png ├── shell.md ├── todo.md └── top-contributors.png ├── entrypoint.sh ├── git-insight.spec ├── logger.sh └── src ├── _completion ├── main.sh └── man └── git-insight.1.md /.gitignore: -------------------------------------------------------------------------------- 1 | build.log 2 | COMMIT.md 3 | 4 | # build artifacts directory 5 | build/* 6 | -------------------------------------------------------------------------------- /.tito/packages/.readme: -------------------------------------------------------------------------------- 1 | the .tito/packages directory contains metadata files 2 | named after their packages. Each file has the latest tagged 3 | version and the project's relative directory. 4 | -------------------------------------------------------------------------------- /.tito/packages/git-insight: -------------------------------------------------------------------------------- 1 | 1.1.6-1 ./ 2 | -------------------------------------------------------------------------------- /.tito/releasers.conf: -------------------------------------------------------------------------------- 1 | [copr] 2 | releaser = tito.release.CoprReleaser 3 | project_name = git-insight 4 | 5 | [yum-f15-x86_64] 6 | releaser = tito.release.YumRepoReleaser 7 | builder = tito.builder.MockBuilder 8 | builder.mock = fedora-15-x86_64 9 | rsync = fedorapeople.org:/srv/repos/dgoodwin/tito/fedora-15/x86_64/ 10 | -------------------------------------------------------------------------------- /.tito/tito.props: -------------------------------------------------------------------------------- 1 | [buildconfig] 2 | builder = tito.builder.Builder 3 | tagger = tito.tagger.VersionTagger 4 | changelog_do_not_remove_cherrypick = 0 5 | changelog_format = %s (%ae) 6 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "conventionalCommits.scopes": [ 3 | "rpm", 4 | "graph", 5 | "zsh", 6 | "completion", 7 | "linux" 8 | ] 9 | } -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM fedora 2 | 3 | RUN dnf install -y 'dnf-command(copr)' && \ 4 | dnf copr enable -y avimehenwal/git-insight 5 | RUN dnf -y --refresh update 6 | RUN dnf install -y tito pandoc make man 7 | 8 | WORKDIR /SOURCES 9 | VOLUME /SOURCES 10 | 11 | ADD ./entrypoint.sh . 12 | COPY . . 13 | 14 | # this is what I need to test 15 | # RUN dnf install -v git-insight 16 | 17 | CMD ["./entrypoint.sh"] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Avi Mehenwal 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | NAME = git-insight 2 | PANDOC := $(shell command -v pandoc 2> /dev/null) 3 | 4 | ARTIFACT_DIR ?= build 5 | MANSECTION ?= 1 6 | MANPAGE.md = $(PANDOC) --standalone $(PANDOCFLAGS) --to man 7 | MANPAGE = $(ARTIFACT_DIR)/$(NAME).$(MANSECTION) 8 | 9 | %.$(MANSECTION): %.$(MANSECTION).md 10 | $(MANPAGE.md) $< -o $@ 11 | 12 | all: man 13 | 14 | pre: 15 | @echo PRE 16 | test -d $(ARTIFACT_DIR) || mkdir -v $(ARTIFACT_DIR) 17 | 18 | compress: 19 | tar -czvf ${HOME}/rpmbuild/SOURCES/git-insight-0.0.1.tar.gz ./src 20 | 21 | build: 22 | docker build -t avi/fedora . && docker images 23 | 24 | # docker run -it --rm -v ${PWD}:/SOURCES/:z avi/fedora bash 25 | run: 26 | docker run -it --rm avi/fedora bash 27 | 28 | # ifDev 29 | # man --local-file src/man/git-insight.1 30 | man: pre 31 | ifdef PANDOC 32 | pandoc --standalone --to man src/man/git-insight.1.md -o $(MANPAGE) 33 | else 34 | @echo "pandoc is not installed, skipping manpages generation" 35 | endif 36 | 37 | local: man 38 | ./entrypoint.sh 39 | 40 | pypi: 41 | pyp2rpm termgraph -t fedora --srpm -b 3 -p 3 -d ./pyDEPS 42 | mock -r fedora-35-x86_64 ./pyDEPS/*.src.rpm 43 | tree ./pyDEPS 44 | 45 | # Wrote: /builddir/build/RPMS/python3-termgraph-0.5.3-1.fc35.noarch.rpm 46 | # fedora only supports python3 now 47 | 48 | clean: 49 | rm -rvf $(MANPAGE) pyDEPS -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # git-insight 2 | 3 | > get browser like colorful insights about a git repository right on your terminal 4 | 5 | [Available as RPM package for fedora, centOS and red-hat linux](https://copr.fedorainfracloud.org/coprs/avimehenwal/git-insight/) 6 | 7 | _ _ _ _ _ _ 8 | __ _(_) |_ (_)_ __ ___(_) __ _| |__ | |_ 9 | / _` | | __|____| | '_ \/ __| |/ _` | '_ \| __| 10 | | (_| | | ||_____| | | | \__ \ | (_| | | | | |_ 11 | \__, |_|\__| |_|_| |_|___/_|\__, |_| |_|\__| 12 | |___/ |___/ 13 | 14 | [![Copr build status](https://copr.fedorainfracloud.org/coprs/avimehenwal/git-insight/package/git-insight/status_image/last_build.png)](https://copr.fedorainfracloud.org/coprs/avimehenwal/git-insight/package/git-insight/) 15 | 16 | ## How to install 17 | 18 | ```bash 19 | sudo dnf copr enable avimehenwal/git-insight 20 | sudo dnf install git-insight 21 | ``` 22 | 23 | ## Usage 24 | 25 | ``` 26 | cd 27 | git-insight 28 | ``` 29 | 30 | ## Demo 31 | 32 | Analysis of current repo using this tool 33 | 34 | ![git-insight repository analysis](docs/repo-analysis.png) 35 | 36 | ## Featured Graphs 37 | 38 | - [x] Number of commites on a day 39 | - [x] Number of files changed, Number of changes (+/-) made on commits 40 | - [x] Trend over entire source history 41 | - [x] Top 10 contributors 42 | - [x] Most frequently updated files 43 | - [x] Branch comparison 44 | 45 | #### :v: Get in touch with me 46 | 47 | > I am looking for Jobs ... :sunglasses: 48 | 49 | - [Github](https://github.com/avimehenwal/) 50 | - [My Website](https://avimehenwal.in) 51 | - [My Blog v2](https://avimehenwal2.netlify.app/) 52 | - [Twitter Handle](https://twitter.com/avimehenwal) 53 | - [LinkedIn](https://in.linkedin.com/in/avimehenwal) 54 | - [Stackoverflow](https://stackoverflow.com/users/1915935/avi-mehenwal) 55 | 56 | Buy Me A Coffee 57 | 58 | Spread Love :hearts: and not :no_entry_sign: hatred [![Twitter Follow](https://img.shields.io/twitter/follow/avimehenwal.svg?style=social)](https://twitter.com/avimehenwal) 59 | 60 | 1. Number of commites on a day 61 | 1. Number of files changed, Number of changes (+/-) made on commits 62 | 1. Trend over entire source history 63 | 1. Top 10 contributors 64 | 1. Most frequently updated files 65 | 1. Branch comparison 66 | -------------------------------------------------------------------------------- /docs/branch-comparison.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avimehenwal/git-insight/428d1a350a129337e07b5126e38fe4027ce39815/docs/branch-comparison.png -------------------------------------------------------------------------------- /docs/critical-files.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avimehenwal/git-insight/428d1a350a129337e07b5126e38fe4027ce39815/docs/critical-files.png -------------------------------------------------------------------------------- /docs/demo-add-dels.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avimehenwal/git-insight/428d1a350a129337e07b5126e38fe4027ce39815/docs/demo-add-dels.png -------------------------------------------------------------------------------- /docs/demo-git-calendar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avimehenwal/git-insight/428d1a350a129337e07b5126e38fe4027ce39815/docs/demo-git-calendar.png -------------------------------------------------------------------------------- /docs/issues.MD: -------------------------------------------------------------------------------- 1 | # Issues 2 | 3 | ## Enable copr in docker image itself 4 | 5 | No such command: copr. Please use /usr/bin/dnf --help 6 | It could be a DNF plugin command, try: "dnf install 'dnf-command(copr)'" 7 | The command '/bin/sh -c dnf copr enable -y avimehenwal/git-insight' returned a non-zero code: 1 8 | 9 | ## build and install RPM inside docker container 10 | 11 | ### CMD not working 12 | 13 | able to install package and run from SHELL but NOT from CMD in docker 14 | 15 | - tried bash 16 | 17 | ## Termgraph 18 | 19 | - color NOT working with calendar graph type 20 | 21 | ## openSUSE 22 | 23 | - completions not working on suse 24 | - fpath is not defined, lazy loading not working 25 | - Allow command to run only inside git repositories 26 | -------------------------------------------------------------------------------- /docs/new-rpm.md: -------------------------------------------------------------------------------- 1 | # RPM Packaging 2 | 3 | - [x] create a new spec file 4 | - [x] build RPM package from source 5 | - [x] tag RPM package 6 | - [ ] publish and release rpm package 7 | - [ ] auto-generate changelog file 8 | - [ ] configure copr-cli 9 | 10 | ``` 11 | rpmdev-setuptree 12 | rpmdev-newspec git-insight 13 | ``` 14 | 15 | [rpm macros documentation](https://docs.fedoraproject.org/en-US/packaging-guidelines/RPMMacros/) 16 | [rpm scriptlets to handle systemd service](https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/) 17 | 18 | ## Building packages 19 | 20 | build from latest committedd source, uncommited source will not be picked 21 | 22 | ``` 23 | rpmlint git-insight.spec 24 | tito build --rpm --test 25 | ``` 26 | 27 | ### Using tito 28 | 29 | ``` 30 | tito tag 31 | tito release copr 32 | ``` 33 | 34 | ### Verify 35 | 36 | ``` 37 | rpm -ql /tmp/tito/noarch/git-insight-0.0.1-1.git.2.a0a31dd.fc35.noarch.rpm 38 | sudo dnf install --refresh git-insight 39 | ``` 40 | 41 | ## Architecture 42 | 43 | Extra Packages for Enterprise Linux (EPEL) - Fedora Docs 44 | 45 | ### Resources 46 | 47 | - [spec file help](https://rpm-packaging-guide.github.io/#what-is-a-spec-file) 48 | - [official spec file macros](https://rpm-software-management.github.io/rpm/manual/spec.html) 49 | - [linux FHS](https://refspecs.linuxfoundation.org/FHS_3.0/fhs-3.0.html) 50 | - [linux FHS /use/share/\* explained](https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch04s11.html) 51 | 52 | ## Questions 53 | 54 | - How to access calendar from your APP ? [calDAV standard](https://en.wikipedia.org/wiki/CalDAV) 55 | 56 | | Command | Meaning | 57 | | --------- | -------------------------------------------------------------------------------------------------------------- | 58 | | chmod 400 | file To protect a file against accidental overwriting. | 59 | | chmod 500 | directory To protect yourself from accidentally removing, renaming or moving files from this directory. | 60 | | chmod 600 | file A private file only changeable by the user who entered this command. | 61 | | chmod 644 | file A publicly readable file that can only be changed by the issuing user. | 62 | | chmod 660 | file Users belonging to your group can change this file, others don't have any access to it at all. | 63 | | chmod 700 | file Protects a file against any access from other users, while the issuing user still has full access. | 64 | | chmod 755 | directory For files that should be readable and executable by others, but only changeable by the issuing user. | 65 | | chmod 775 | file Standard file sharing mode for a group. | 66 | | chmod 777 | file Everybody can do everything to this file. | 67 | 68 | ## pyp2RPM packaging dependencies 69 | 70 | tool generates 3 output files 71 | 72 | Output: ['python-termgraph-0.5.3-1.fc34.src.rpm', 'python-termgraph.spec', 'termgraph-0.5.3.tar.gz'] 73 | 74 | Requires ONLY accepts RPMs, How to create RPM? 75 | using mock, tito tool 76 | -------------------------------------------------------------------------------- /docs/repo-analysis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avimehenwal/git-insight/428d1a350a129337e07b5126e38fe4027ce39815/docs/repo-analysis.png -------------------------------------------------------------------------------- /docs/shell.md: -------------------------------------------------------------------------------- 1 | # SHELL Scripting 2 | 3 | ## Bash 4 | 5 | [GNU Bash Reference Manual](https://www.gnu.org/software/bash/manual/html_node/index.html#SEC_Contents) 6 | 7 | - [shell expansion](https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html) 8 | - [terminal colors using tput](https://tldp.org/HOWTO/Bash-Prompt-HOWTO/x405.html) 9 | 10 | ``` 11 | for i in {1..16} 12 | do 13 | echo "$(tput setab ${i})Hello, world$(tput sgr0)" 14 | echo "$(tput setaf ${i})Hello, world$(tput sgr0)" 15 | done 16 | echo "$(tput bold)Hello, world$(tput sgr0)" 17 | echo "$(tput dim)Hello, world$(tput sgr0)" 18 | echo "$(tput smul)Hello, world$(tput sgr0)" 19 | echo "$(tput rmul)Hello, world$(tput sgr0)" 20 | echo "$(tput rev)Hello, world$(tput sgr0)" 21 | echo "$(tput smso)Hello, world$(tput sgr0)" 22 | echo "$(tput rmso)Hello, world$(tput sgr0)" 23 | echo "$(tput blink)Title of the Program$(tput sgr0)" 24 | ``` 25 | 26 | ## character encoding 27 | 28 | what is see is different from how computer stores it. 29 | 30 | Technically, ANSI should be the same as US-ASCII. It refers to the ANSI X3.4 standard, which is simply the ANSI organisation's ratified version of ASCII. Use of the top-bit-set characters is not defined in ASCII/ANSI as it is a 7-bit character set. 31 | 32 | ## Command Completions 33 | 34 | - Is bash completion different from zsh completion? 35 | 36 | Zsh Completion with Homebrew: This works exactly the same as bash completion. brew install zsh-completions. 37 | 38 | ### BASH 39 | 40 | complete -W "list of arguments as words" COMMAND 41 | 42 | #### from a completion function 43 | 44 | compgen 45 | 46 | https://iridakos.com/programming/2018/03/01/bash-programmable-completion-tutorial 47 | 48 | ### load completions from bash --> zsh 49 | 50 | ``` 51 | autoload -U +X compinit && compinit 52 | autoload -U +X bashcompinit && bashcompinit 53 | source /path/to/your/bash_completion_script 54 | ``` 55 | 56 | Bash has awesome in built auto completion support but the bash autocomplete scripts don't work directly zsh as zsh environment doesn't have the essential bash autocomplete helper functions like compgen, complete. It does so in an effort to keep zsh session fast. 57 | 58 | These days zsh is shipped with appropriate completion scripts like compinit and bashcompinit which have the required functions to support bash autocomplete scripts. 59 | 60 | autoload : Note that autoload is defined in zsh and not bash. autoload looks for a file named in the directory paths returned by fpath command and marks a function to load the same when it is first invoked. 61 | 62 | -U: Ignore any aliases when loading a function like compinit or bashcompinit 63 | +X: Just load the named function fow now and don't execute it 64 | 65 | https://stackoverflow.com/a/27853970/1915935 66 | 67 | ##### How to test autoloading functions 68 | 69 | ``` 70 | echo ${functions[calendar]} 71 | calendar 72 | echo ${functions[calendar]} 73 | ``` 74 | 75 | ## ZSH 76 | 77 | - Autoloading functions `autoload` builtin (or `functions -u` or `typeset -fu`) 78 | - List all functions that shell knows about, `functions` (including Autoloading) 79 | - `functions` is an associative array, use parameter expansion `${(k)functions}` to print all kV 80 | - autoloading functions are marked as `::` in `functions` output `echo ${functions[spaceship::union]}` 81 | - OPTIMIZATION: Thus including an element such as ‘/usr/local/funcs.zwc’ in fpath will speed up the search for functions, with the disadvantage that functions included must be explicitly recompiled by hand before the shell notices any changes. 82 | - To load the definition of an autoloaded function myfunc without executing myfunc, use: `autoload +X myfunc` 83 | 84 | ``` 85 | unfunction myfunc 86 | autoload myfunc 87 | myfunc args 88 | 89 | echo ${(kv)functions[myfunc]} 90 | 91 | autoload +X myfunc 92 | ``` 93 | 94 | - Hook Functions `chpwd`, `periodic`, `precmd`, `preexec`, `zshaddhistory`, `zshexit` 95 | - TRAP Functions 96 | - add new path to fpath `fpath+=~/avimehenwal` 97 | - ZSH Builtin commands 98 | - `$` is a [Parameter in ZSH](https://zsh.sourceforge.io/Doc/Release/Parameters.html#Parameters) 99 | - If a `${...}` type parameter expression or a `$(...)` type command substitution 100 | 101 | ``` 102 | print -C3 {1..9} 103 | print -l {1..9} 104 | ``` 105 | 106 | - Array manipulation 107 | - additions, deletions 108 | - traversal 109 | - slicing `${array[4,7]}` 110 | - element access `${array[-1]}` 111 | - element search 112 | 113 | o | sorting 114 | i,I | test if element is in array or not 115 | u | remove repetitive 116 | f | construct arrays from file 117 | U, L | transform string to uppercase, lowercase 118 | (M) | negate the pattern 119 | :# | exclude search patern, like grep -v 120 | t | print TYPE parameter expansion 121 | 122 | ``` 123 | print -l ${(M)fpath:#*avimehenwal*} 124 | 125 | # get the type of parateter using parameter expansion 126 | print -rl -- ${(t)fpath} 127 | ``` 128 | 129 | - Use calendar system provided by ZSH 130 | 131 | ## ZSH Completion 132 | 133 | Zsh has two completion systems, an old, so called **compctl** completion (named after the builtin command that serves as its complete and only user interface), and a new one, referred to as **compsys**, organized as library of builtin and user-defined functions. The two systems differ in their interface for specifying the completion behavior. The new system is more customizable and is supplied with completions for many commonly used commands; it is therefore to be preferred. 134 | 135 | 1. compctl (old) 136 | 2. [compsys system](https://zsh.sourceforge.io/Doc/Release/Completion-System.html#Completion-System) (new) 137 | 138 | ``` 139 | zle -C complete expand-or-complete completer 140 | ``` 141 | 142 | key-press-binding --> completion widget --> completion gen function 143 | 144 | - Completion functions for commands are stored in files with names beginning with an underscore **\_,** 145 | - completion files are lazy loaded, should be in `fpath` 146 | - The `_arguments`, `_describe` function is a wrapper around the `compadd` builtin function 147 | 148 | ### Resources 149 | 150 | - [completion widgets](https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Completion) 151 | - [resource 1](https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org) 152 | -------------------------------------------------------------------------------- /docs/todo.md: -------------------------------------------------------------------------------- 1 | # Todo 2 | 3 | - [x] man pages 4 | - [ ] application data /opt, /var or FHS specific place 5 | - [ ] test 6 | - [x] proper logs in /var/logs 7 | - [ ] shell completions 8 | - [ ] [zsh autoloading functions](https://unix.stackexchange.com/a/33898/32890) 9 | - [ ] coloured echoed console logs 10 | 11 | ## Man pages 12 | 13 | ``` 14 | $PREFIX/share/man/man$SECTION/$NAME.$SECTION 15 | pandoc --standalone --to man hello.1.md -o hello.1 16 | man --local-file sample.1 17 | ``` 18 | 19 | [sample man-page in markdown format](https://gist.githubusercontent.com/eddieantonio/55752dd76a003fefb562/raw/38f6eb9de250feef22ff80da124b0f439fba432d/hello.1.md) 20 | 21 | ### Other ideas 22 | 23 | [list which docs are available in html format on my machine?](https://superuser.com/questions/157996/utilities-for-find-open-linux-usr-share-docs) 24 | 25 | firefox $(find /usr/share/doc -type f -name 'index.html' -print | sed '52q;d') 26 | -------------------------------------------------------------------------------- /docs/top-contributors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avimehenwal/git-insight/428d1a350a129337e07b5126e38fe4027ce39815/docs/top-contributors.png -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # AUTHOR : avimehenwal 4 | # DATE : 13-Nov-2021 5 | # PURPOSE : RPM test script 6 | # FILENAME : test-script.sh 7 | # 8 | # Long problem description 9 | 10 | BUILD_LOG="./build/build.log" 11 | NAME="git-insight" 12 | 13 | tito build --rpm --test | tee ${BUILD_LOG} 14 | 15 | RPM=$(awk 'END{print $2}' ${BUILD_LOG}) 16 | echo "RPM => ${RPM}" 17 | [ -f "${RPM}" ] && echo "RPM exists ==> ${RPM}" || echo "RPM DOES NOT Exist ==> ${RPM}" 18 | 19 | remove_pkg() { 20 | sudo dnf remove -y ${NAME} 21 | } 22 | 23 | rpm -q ${NAME} && remove_pkg 24 | BEFORE="before = $(ls /usr/bin | wc)" 25 | sudo dnf localinstall -y ${RPM} 26 | AFTER="after = $(ls /usr/bin | wc)" 27 | 28 | # run 29 | git-insight 30 | 31 | echo -e "$BEFORE \n $AFTER" 32 | echo -e "Files installed on system = $(rpm -ql ${RPM} | wc -l)" 33 | rpm -ql ${RPM} 34 | 35 | # END 36 | -------------------------------------------------------------------------------- /git-insight.spec: -------------------------------------------------------------------------------- 1 | Name: git-insight 2 | Version: 1.1.6 3 | Release: 1%{?dist} 4 | Summary: get browser like colorful insights about a git repository on terminal 5 | License: MIT 6 | URL: https://github.com/avimehenwal/git-insight 7 | Source0: %{name}-%{version}.tar.gz 8 | BuildArch: noarch 9 | 10 | BuildRequires: pandoc make 11 | Requires: bash >= 5.1.8 12 | Requires: coreutils sed git fzf 13 | Requires: python3-termgraph 14 | 15 | 16 | %description 17 | %{Summary} 18 | 19 | Use it inside any directory 20 | 21 | %prep 22 | # 1. unzip, unpacking sources 23 | # 2. apply patches 24 | %autosetup 25 | 26 | %pre 27 | 28 | %build 29 | make man 30 | 31 | %install 32 | mkdir -p %{buildroot}/%{_bindir} 33 | install --mode=755 -v src/main.sh %{buildroot}%{_bindir}/%{name} 34 | install -D --mode=644 -v build/%{name}.1 %{buildroot}%{_mandir}/man1/%{name}.1 35 | install -D --mode=644 -v src/_completion %{buildroot}/usr/local/share/zsh/site-functions/_%{name} 36 | 37 | %files 38 | %{_bindir}/%{name} 39 | %{_mandir}/man1/%{name}.1.gz 40 | /usr/local/share/zsh/site-functions/_%{name} 41 | 42 | %changelog 43 | * Wed Dec 15 2021 avimehenwal 1.1.6-1 44 | - build(rpm): :zap: pypi -> rpm (avi.mehanwal@gmail.com) 45 | 46 | * Tue Nov 16 2021 avimehenwal 1.1.5-1 47 | - feat(linux): :coffin: enable syslog (avi.mehanwal@gmail.com) 48 | - fix: :lock: run only in GIT enabled directories (avi.mehanwal@gmail.com) 49 | 50 | * Tue Nov 16 2021 avimehenwal 1.1.4-1 51 | - fix: :bug: make it work on openSUSE (avi.mehanwal@gmail.com) 52 | - docs: :speech_balloon: add badge (avi.mehanwal@gmail.com) 53 | 54 | * Mon Nov 15 2021 avimehenwal 1.1.3-1 55 | - feat(completion): :dizzy: add help to completion (avi.mehanwal@gmail.com) 56 | - feat: :tada: accept arguments for subcommands (avi.mehanwal@gmail.com) 57 | - feat: :bookmark: add help option to usage API (avi.mehanwal@gmail.com) 58 | - docs: :ambulance: readme (avi.mehanwal@gmail.com) 59 | 60 | * Sun Nov 14 2021 avimehenwal 1.1.2-1 61 | - feat(zsh): :fire: add auto completions (avi.mehanwal@gmail.com) 62 | - docs: :memo: sales pitch (avi.mehanwal@gmail.com) 63 | 64 | * Sun Nov 14 2021 avimehenwal 1.1.1-1 65 | - feat(graph): :sparkles: total 6 graphs (avi.mehanwal@gmail.com) 66 | 67 | * Sun Nov 14 2021 avimehenwal 1.1.0-1 68 | - feat(graph): :zap: git commit trend calendar (avi.mehanwal@gmail.com) 69 | 70 | * Sat Nov 13 2021 avimehenwal 1.0.0-1 71 | - feat(graph): :art: add add/del stacked graph (avi.mehanwal@gmail.com) 72 | 73 | * Sat Nov 13 2021 avimehenwal 0.0.3-1 74 | - feat(rpm): :memo: add manpage (avi.mehanwal@gmail.com) 75 | - test(rpm): :test_tube: build and install rpm into a docker fedora image 76 | (avi.mehanwal@gmail.com) 77 | - build(rpm): :package: remove group from preamble (avi.mehanwal@gmail.com) 78 | - fix: install it on docker fedora (avi.mehanwal@gmail.com) 79 | 80 | * Sat Nov 13 2021 avimehenwal 0.0.2-1 81 | - build: :bug: use py3 instead of py2 (avi.mehanwal@gmail.com) 82 | - build(rpm): remove awk from Requires (avi.mehanwal@gmail.com) 83 | - Automatic commit of package [git-insight] release [0.0.1-1]. 84 | (avi.mehanwal@gmail.com) 85 | 86 | * Sat Nov 13 2021 avimehenwal 0.0.1-1 87 | - new package built with tito 88 | 89 | * Sat Nov 13 2021 avimehenwal 0.0.1-1 90 | - new package built with tito -------------------------------------------------------------------------------- /logger.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # AUTHOR : avimehenwal 4 | # CREATED : Sat Nov 13 04:55:12 PM CET 2021 5 | # PURPOSE : 6 | 7 | # logger --tag "APP-LABEL" --id=$$ 8 | 9 | for num in {1..7} 10 | do 11 | 12 | logger --journald < ${@}" 206 | exit 0 207 | } 208 | 209 | not_a_git_repo() { 210 | local error="command called from a non git-root directory -> ${PWD}" 211 | local error_desc="kindly use this command from the root of a git initialized repo" 212 | echo "${error}\n${error_desc}" && WARN "${error}" 213 | exit 1 214 | } 215 | 216 | track_program_call() { 217 | DEBUG "graph requested -> ${1}" 218 | } 219 | 220 | test -d ${PWD}/.git || not_a_git_repo 221 | 222 | if [ $# -eq 0 ] 223 | then 224 | all_insights 225 | else 226 | [[ $# -gt 2 ]] && print_usage_n_exit ${@} 227 | subcmd=$1 228 | shift 229 | subcmd_args=${@} 230 | case ${subcmd} in 231 | "graph_git_commit" ) 232 | graph_git_commit ${subcmd_args} 233 | track_program_call ${subcmd};; 234 | "graph_git_trend" ) 235 | graph_git_trend ${subcmd_args} 236 | track_program_call ${subcmd};; 237 | "graph_git_leaderboard" ) 238 | graph_git_leaderboard ${subcmd_args} 239 | track_program_call ${subcmd};; 240 | "graph_git_hot_files" ) 241 | graph_git_hot_files ${subcmd_args} 242 | track_program_call ${subcmd};; 243 | "graph_branch_comparison" ) 244 | graph_branch_comparison ${subcmd_args} 245 | track_program_call ${subcmd};; 246 | "calendar_graph_git_log" ) 247 | calendar_graph_git_log ${subcmd_args} 248 | track_program_call ${subcmd};; 249 | -h | --help | * ) 250 | print_usage_n_exit ${subcmd};; 251 | esac 252 | fi 253 | 254 | # END 255 | -------------------------------------------------------------------------------- /src/man/git-insight.1.md: -------------------------------------------------------------------------------- 1 | % GIT-INSIGHT(1) Version 0.2 | git-insight "git visualizer" Documentation 2 | 3 | # NAME 4 | 5 | **git-insight** — prints git statistics The Visual Way 6 | 7 | # SYNOPSIS 8 | 9 | | **hello** \[**-o** | **--out** _file_] \[_dedication_] 10 | | **hello** \[**-h** | **--help**|**-v**|**--version**] 11 | 12 | # EXAMPLES 13 | 14 | _some command_ 15 | 16 | : Per-user default dedication file. 17 | 18 | # DESCRIPTION 19 | 20 | Prints "Hello, _dedication_!" to the terminal. If no dedication is 21 | given, uses the default dedication. The default dedication is chosen by 22 | the following sequence: 23 | 24 | 1. Using the environment variable _DEFAULT_HELLO_DEDICATION_ 25 | 2. Using the per-user configuration file, _~/.hellorc_ 26 | 3. Using the system-wide configuration file, _/etc/hello.conf_ 27 | 4. Finally, using "world". 28 | 29 | ## Options 30 | 31 | -h, --help 32 | 33 | : Prints brief usage information. 34 | 35 | -o, --output 36 | 37 | : Outputs the greeting to the given filename. 38 | 39 | The file must be an **open(2)**able and **write(2)**able file. 40 | 41 | -v, --version 42 | 43 | : Prints the current version number. 44 | 45 | # FILES 46 | 47 | _~/.hellorc_ 48 | 49 | : Per-user default dedication file. 50 | 51 | _/etc/hello.conf_ 52 | 53 | : Global default dedication file. 54 | 55 | # ENVIRONMENT 56 | 57 | **DEFAULT_HELLO_DEDICATION** 58 | 59 | : The default dedication if none is given. Has the highest precedence 60 | if a dedication is not supplied on the command line. 61 | 62 | # BUGS 63 | 64 | See GitHub Issues: 65 | 66 | # AUTHOR 67 | 68 | Avi Mehenwal 69 | 70 | # SEE ALSO 71 | 72 | **hi(1)**, **hello(3)**, **hello.conf(4)** 73 | --------------------------------------------------------------------------------