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