2020-06-03 10:26:15 +00:00
|
|
|
# Tools
|
2020-10-07 19:46:34 +00:00
|
|
|
alias g="git"
|
2020-03-08 19:18:49 +00:00
|
|
|
|
2021-06-04 11:43:56 +00:00
|
|
|
y() {
|
2021-11-24 19:16:31 +00:00
|
|
|
local unignore="$XDG_CONFIG_HOME/yadm/unignore"
|
2021-11-04 11:14:50 +00:00
|
|
|
test -r "$unignore" && cat "$unignore" | while read f; do eval ls -d $f; done | yadm add --intent-to-add --pathspec-from-file=-
|
2021-06-04 11:43:56 +00:00
|
|
|
test "$#" -eq 0 && yadm s || yadm "$@"
|
|
|
|
}
|
2020-11-26 19:38:26 +00:00
|
|
|
yc() {
|
2022-03-06 21:04:22 +00:00
|
|
|
local folder="$(test -e "${1:-$PWD}" && realpath "${1:-$PWD}" || echo "$XDG_CONFIG_HOME/$1")"
|
|
|
|
echo "${folder#$HOME\/.}:" >/tmp/yc-msg
|
|
|
|
yadm commit -v --template /tmp/yc-msg ${@:2} -- "$folder*"
|
2020-11-26 19:38:26 +00:00
|
|
|
}
|
|
|
|
|
2021-05-02 17:37:18 +00:00
|
|
|
gcn() {
|
2021-11-24 19:16:31 +00:00
|
|
|
local root="$(git rev-parse --show-toplevel)"
|
2021-10-27 08:07:27 +00:00
|
|
|
if test "$root" = "$DATA"
|
2021-05-02 17:37:18 +00:00
|
|
|
then
|
2021-11-11 11:15:41 +00:00
|
|
|
if test $# -eq 0 || test -e "$1"
|
2021-10-27 08:07:27 +00:00
|
|
|
then
|
|
|
|
fulldir="$(realpath ${1:-$PWD})"
|
|
|
|
dir="${fulldir#$root/*/}"
|
|
|
|
else
|
2021-11-23 09:20:04 +00:00
|
|
|
dir="box/$1"
|
2021-10-27 08:07:27 +00:00
|
|
|
fulldir="$root/2-standards/$dir"
|
|
|
|
fi
|
2021-05-02 17:37:18 +00:00
|
|
|
else
|
2021-10-27 08:07:27 +00:00
|
|
|
fulldir="$(realpath ${1:-$PWD})"
|
|
|
|
dir="${fulldir#$root/}"
|
2021-05-02 17:37:18 +00:00
|
|
|
fi
|
2021-11-23 09:20:04 +00:00
|
|
|
echo "$dir: " >/tmp/gcn-msg
|
|
|
|
git add $fulldir
|
|
|
|
git moves -q
|
|
|
|
git commit -v --template /tmp/gcn-msg ${@:2} #-- $fulldir
|
2021-05-02 17:37:18 +00:00
|
|
|
}
|
|
|
|
|
2020-06-26 21:25:53 +00:00
|
|
|
# if in home or under XDG_CONFIG_HOME and not within a git directory, replace git by yadm
|
2020-06-08 09:42:34 +00:00
|
|
|
git() {
|
2020-10-08 09:11:51 +00:00
|
|
|
case "$1" in
|
2022-01-05 17:42:20 +00:00
|
|
|
(reset) test "$2" = "--hard" && return 66;;
|
|
|
|
(config) ;;
|
|
|
|
(clone) ;;
|
|
|
|
(*) case "$PWD" in
|
|
|
|
($HOME|$XDG_CONFIG_HOME|$LAST_YADM)
|
2020-10-08 09:11:51 +00:00
|
|
|
yadm "$@"
|
2022-01-05 17:42:20 +00:00
|
|
|
return $?
|
|
|
|
;;
|
|
|
|
($XDG_CONFIG_HOME*|$HOME/.local*)
|
|
|
|
if ! command git rev-parse --show-toplevel &>/dev/null; then
|
|
|
|
export LAST_YADM="$PWD"
|
|
|
|
yadm "$@"
|
|
|
|
return $?
|
|
|
|
fi;;
|
2020-10-08 09:11:51 +00:00
|
|
|
esac;;
|
|
|
|
esac
|
2022-01-05 17:42:20 +00:00
|
|
|
command git "$@"
|
2020-06-08 09:42:34 +00:00
|
|
|
}
|
|
|
|
|
2020-11-13 11:49:24 +00:00
|
|
|
# BRANCHES
|
2020-06-03 10:26:15 +00:00
|
|
|
# Remove list of tags local & remote
|
2020-03-08 19:18:49 +00:00
|
|
|
gitrmtag() {
|
2020-10-08 09:11:51 +00:00
|
|
|
declare -a refs
|
|
|
|
local index=1
|
|
|
|
for tag in $@; do refs[index++]=":refs/tags/$tag"; done
|
|
|
|
git push origin "${refs[@]}" && git tag -d "$@"
|
2020-03-08 19:18:49 +00:00
|
|
|
}
|
2020-06-03 10:26:15 +00:00
|
|
|
# Rename a tag
|
2020-03-08 19:18:49 +00:00
|
|
|
gitretag() {
|
2020-10-08 09:11:51 +00:00
|
|
|
git push origin refs/tags/${1}:refs/tags/${2} :refs/tags/$1 && git tag -d $1
|
2020-03-08 19:18:49 +00:00
|
|
|
}
|
|
|
|
|
2020-06-03 10:26:15 +00:00
|
|
|
# Testing
|
2021-02-16 12:08:56 +00:00
|
|
|
gittestcommit() { touch file$((++i)) && git add 'file*' && git commit -m "Create file$i"; }
|