File: git-info

package info (click to toggle)
git-extras 6.1.0-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 1,720 kB
  • sloc: sh: 3,480; makefile: 126
file content (79 lines) | stat: -rwxr-xr-x 1,575 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash

GREEN="$(tput setaf 2)"
NORMAL="$(tput sgr0)"
if [ "$1" = "--color" ] || [ "$2" = "--color" ] || \
     [ "$1" = "-c" ] || [ "$2" = "-c" ] ; then
  COLOR_TITLE="$GREEN"
else
  COLOR_TITLE="$NORMAL"
fi

HIDE_CONFIG=
if [ "$1" != "--no-config" ] && [ "$2" != "--no-config" ]; then
  HIDE_CONFIG=1
fi

get_config() {
  cmd_get_config="$(git config --get-all git-extras.info.config-grep)"
  if [ -z "$cmd_get_config" ]; then
    git config --list
  else
    eval "$cmd_get_config"
  fi
}

most_recent_commit() {
  cmd_get_log="$(git config --get-all git-extras.info.log)"
  if [ -z "$cmd_get_log" ]; then
    git log --max-count=1 --pretty=short
  else
    eval "$cmd_get_log"
  fi
}

submodules() {
  # short sha1
  git submodule status | sed 's/\([^abcdef0-9]\{0,2\}\)\([abcdef0-9]\{7\}\)\([abcdef0-9]\{33\}\)\(.*\)/\1\2\4/'
}

local_branches() {
  git branch
}

remote_branches() {
  git branch -r
}

remote_urls() {
  git remote -v
}

echon() {
  echo "$@"
  echo
}

echo
echon "${COLOR_TITLE}## Remote URLs:${NORMAL}"
echon "$(remote_urls)"

echon "${COLOR_TITLE}## Remote Branches:${NORMAL}"
echon "$(remote_branches)"

echon "${COLOR_TITLE}## Local Branches:${NORMAL}"
echon "$(local_branches)"

SUBMODULES_LOG=$(submodules)
if [ ! -z "$SUBMODULES_LOG" ]; then
  echon "${COLOR_TITLE}## Submodule(s):${NORMAL}"
  echon "$SUBMODULES_LOG"
fi

echon "${COLOR_TITLE}## Most Recent Commit:${NORMAL}"
echon "$(most_recent_commit)"

if [ ! -z "$HIDE_CONFIG" ]; then
  echon "${COLOR_TITLE}## Configuration (.git/config):${NORMAL}"
  echon "$(get_config)"
fi