File: git-extras

package info (click to toggle)
git-extras 7.4.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 2,120 kB
  • sloc: sh: 4,312; python: 994; makefile: 146
file content (54 lines) | stat: -rwxr-xr-x 1,310 bytes parent folder | download
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
#!/usr/bin/env bash

VERSION="7.4.0"
INSTALL_SCRIPT="https://raw.githubusercontent.com/tj/git-extras/main/install.sh"

update() {
  local bin="$(command -v git-extras)"
  local prefix=${bin%/*/*}
  local orig=$PWD

  curl -s $INSTALL_SCRIPT | PREFIX="$prefix" bash /dev/stdin \
    && cd "$orig" \
    && echo "... updated git-extras $VERSION -> $(git extras --version)"
}

updateForWindows() {
  local bin="$(command -v git-extras)"
  local prefix=${bin%/*/*}
  local orig=$PWD

  # we need to clean up /tmp manually on windows
  cd /tmp \
    && rm -rf ./git-extras \
    && echo "Setting up 'git-extras'...." \
    && git clone https://github.com/tj/git-extras.git &> /dev/null \
    && cd git-extras \
	&& git checkout \
        $(git describe --tags $(git rev-list --tags --max-count=1)) \
        &> /dev/null \
	&& ./install.cmd "$prefix" \
	&& cd "$orig" \
	&& echo "... updated git-extras $VERSION -> $(git extras --version)"
  rm -rf /tmp/git-extras &> /dev/null
}

case "$1" in
  -v|--version)
    echo $VERSION && exit 0
    ;;
  update)
    platform=$(uname -s)
    if [ "${platform::9}" = "CYGWIN_NT" ] || \
      [ "${platform::5}" = "MINGW" ] || \
      [ "${platform::7}" = "MSYS_NT" ]
    then
      updateForWindows
    else
      update
    fi
    ;;
  *)
    git extras --help
    ;;
esac