Browse Source

Добавлены различные скрипты для работы с git

master
Maxim Likhachev 6 years ago committed by Maxim Likhachev
parent
commit
fa255ee083
  1. 11
      README.md
  2. 19
      forks
  3. 42
      git-aliases
  4. 26
      git-forks
  5. 17
      git-graphviz
  6. 43
      git-ignore
  7. 0
      git-makeignore
  8. 12
      git-top

11
README.md

@ -76,10 +76,17 @@ will create the symbolic link for each script in the \<path> directory. @@ -76,10 +76,17 @@ will create the symbolic link for each script in the \<path> directory.
- [doctools2man](doctools2man) converts doctool to man pages.
- [robodoc2html](robodoc2html) converts a documentation in the robodoc format into html.
- [getignore](getignore) stores files with '+GITIGNORE' marks into .gitignore file.
- [forks](forks) shows the latest forks of github repository.
- [utable](utable) shows a Unicode table.
### Git
- [git-aliases](git-aliases) shows a commented list of all git aliases.
- [git-forks](git-forks) shows the latest forks of github repository.
- [git-graphviz](git-graphviz) creates dot-graph of a git repository.
- [git-ignore](git-ignore) gets specified gitignore settings from [https://gitignore.io/](https://gitignore.io/) website.
- [git-makeignore](git-makeignore) stores files with '+GITIGNORE' marks into .gitignore file.
- [git-top](git-top) shows the most edited files in current git repository.
## WM
- [calculator](calculator) computes mathematical expressions with variables and intermediate values.

19
forks

@ -1,19 +0,0 @@ @@ -1,19 +0,0 @@
#!/bin/bash
#Создан: вт 15 окт 2019 11:15:12
#Изменён: вт 15 окт 2019 21:31:41
API="https://api.github.com/repos/"
last_forks() {
curl -sq "${API}${1}/forks?sort=stargazers&per_page=100" \
| jq -r '.[] | "\(.updated_at) \(.full_name)"' 2>&- \
| sed "s|^| |; s|T| |; s|Z | https://github.com/|" \
| sort -r \
| head -n "${2:-15}"
}
repository="${1?"USAGE $(basename "$0") user/repository ?top?"}"
last_forks "$repository" "$2"

42
git-aliases

@ -0,0 +1,42 @@ @@ -0,0 +1,42 @@
#!/bin/bash
#Создан: чт 14 ноя 2019 14:03:43
#Изменён: чт 14 ноя 2019 17:34:38
# Список псевдонимов git
#
# Формат:
#
# # Комментарий
# name = function
#
# Игнорирование в выводе:
#
# # noindex Комментарий
# или
# name = function #noindex
#
green="\033[1;32m"
rstc="\033[00m"
GITCONFIG=~/.gitconfig
GIT_ALIASES=$(git config --get-regexp 'alias.*' | sed 's/alias.//' | sed 's/ .*//')
while read -r alias; do
line=$(\grep -n -E "^\s*${alias}\s+" "$GITCONFIG")
number=${line/:*}
full_alias=${line/*:}
name=$(sed "s/^[[:space:]]*//; s/=.*$//g; ${number}q;d" $GITCONFIG)
commentary=$(sed "s/[[:space:]]*# //; $((--number))q;d" $GITCONFIG)
if [[ ! "$full_alias" =~ "noindex" ]] && [[ ! "$commentary" =~ "noindex" ]]; then
printf " • ${green}%-15s${rstc}- %s\n" "$name" "$commentary"
fi
done <<<"$GIT_ALIASES"

26
git-forks

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
#!/bin/bash
#Создан: вт 15 окт 2019 11:15:12
#Изменён: чт 14 ноя 2019 17:35:25
# Список форков репозитория на github.com,
# отсортированный на основе времени последних изменений
API="https://api.github.com/repos/"
last_forks() {
curl -sq "${API}${1}/forks?sort=stargazers&per_page=100" \
| jq -r '.[] | "\(.updated_at) \(.full_name)"' 2>&- \
| sed "s|^| |; s|T| |; s|Z | https://github.com/|" \
| sort -r \
| head -n "$2"
}
if [ -z "$1" ]; then
repository=$(git url | grep github.com | sed -e 's|^.*github.com/||' | sed 's/.git.*$//')
else
repository="$1"
fi
last_forks "$repository" "${2:-15}"

17
git-graphviz

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
#!/bin/bash
# Создание графа коммитов git-репозитория
# This produces output that can be displayed using dotty, for example:
# $ git graphviz HEAD~100..HEAD~60 | dotty /dev/stdin
# $ git graphviz --first-parent master | dotty /dev/stdin
# Note how defining a function eliminates the need to use sh -c.
make_graphviz() {
echo 'digraph git {'
git log --pretty='format: %h -> { %p }' "$@" | sed 's/[0-9a-f][0-9a-f]*/\"&\"/g'
echo '}'
}
make_graphviz "$@"

43
git-ignore

@ -0,0 +1,43 @@ @@ -0,0 +1,43 @@
#!/bin/bash
# Получение шаблона gitignore с сайта gitignore.io
ROOT=$(git root 2>&-)
TYPES=()
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-w|--write)
WRITE=1
shift
;;
*)
TYPES+=("$1")
shift
;;
esac
done
set -- "${TYPES[@]}"
if [ "${#TYPES[@]}" -gt 0 ]; then
for t in "${TYPES[@]}"; do
if [ -n "$WRITE" ] && [ -n "$ROOT" ]; then
echo "# $t"
curl -sq "https://gitignore.io/api/${t}" >> "$(git root)/.gitignore"
else
curl -sq "https://gitignore.io/api/${t}"
fi
done
if [ -n "$WRITE" ] && [ -n "$ROOT" ]; then
echo "Ignoring list saved to ${ROOT}/.gitignore file."
fi
else
echo "USAGE: $(basename "$0") [-w/--write] type1 type2 [...]"
exit 1
fi

0
getignore → git-makeignore

12
git-top

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
#!/bin/bash
# Наиболее часто изменяемые файлы git-репозитория
git log --all -M -C --name-only --format='format:' "$@" \
| grep . \
| sort \
| uniq -c \
| sort -rn \
| head -n 20 \
| sed -e 's/^ //'
Loading…
Cancel
Save