diff --git a/home/.chezmoitemplates/get-github-head-revision b/home/.chezmoitemplates/get-github-head-revision index c147602..b6324f1 100644 --- a/home/.chezmoitemplates/get-github-head-revision +++ b/home/.chezmoitemplates/get-github-head-revision @@ -4,7 +4,7 @@ {{- if hasKey $revisions $repo -}} {{- get $revisions $repo -}} {{- else -}} -{{- $result := output "git" "ls-remote" (printf "https://github.com/%s.git" $repo) "HEAD" | trimSuffix "HEAD\n" | trim -}} +{{- $result := output "env" "GIT_CONFIG_GLOBAL=" "git" "ls-remote" (printf "https://github.com/%s.git" $repo) "HEAD" | trimSuffix "HEAD\n" | trim -}} {{- $_ := set $revisions $repo $result -}} {{- $result -}} {{- end -}} diff --git a/home/dot_gitconfig.tmpl b/home/dot_gitconfig.tmpl index 9868065..4cf313b 100644 --- a/home/dot_gitconfig.tmpl +++ b/home/dot_gitconfig.tmpl @@ -37,10 +37,33 @@ path = ~/.config/gitalias/gitalias.txt caa = commit --amend --all caane = commit --amend --all --no-edit cob = checkout -b -apply-gitignore = "!f() { set -ex; git rm -r --cached . >/dev/null; git add .; }; f" -remote-for-branch = "!f() { set -ex; branch="${1:-"$(git current-branch)"}"; git rev-parse --abbrev-ref --symbolic-full-name "${branch}@{upstream}" | sed -n 's,^\\(\\S*\\)/'"${branch}"'$,\\1,p'; }; f" -rr = "!f() { set -ex; branch="${1:-"$(git current-branch)"}"; remote="$(git remote-for-branch "${branch}")"; git reset --hard "${remote}/${branch}"; }; f" -pfor = "!f() { set -ex; branch="${1:-"$(git current-branch)"}"; remote="$(git remote-for-branch "${branch}")"; git push "${remote}" "HEAD:refs/for/${branch}"; }; f" -psfor = "!f() { set -ex; git caane; git pfor "$@"; }; f" -pdraft = "!f() { set -ex; branch="${1:-"$(git current-branch)"}"; remote="$(git remote-for-branch "${branch}")"; git push "${remote}" "HEAD:refs/drafts/${branch}"; }; f" -psdraft = "!f() { set -ex; git caane; git pdraft "$@"; }; f" +apply-gitignore = "!f() { \ + set -ex; \ + git rm -r --cached . >/dev/null; \ + git add .; \ +};f" +remote-for-branch = "!f() { \ + set -ex; \ + branch="${1:-"$(git current-branch)"}"; \ + git rev-parse --abbrev-ref --symbolic-full-name "${branch}@{upstream}" | sed -n 's,^\\(\\S*\\)/'"${branch}"'$,\\1,p' | grep .; \ +};f" +rr = "!f() { \ + set -ex; \ + branch="${1:-"$(git current-branch)"}"; \ + remote="$(git remote-for-branch "${branch}")"; \ + git reset --hard "${remote}/${branch}"; \ +};f" +pfor = "!f() { \ + set -ex; \ + branch="$(echo "${1}" | cut -d'%' -f1)"; \ + branch="${branch:-"$(git current-branch)"}"; \ + push_opts="$(echo "${1}" | cut -d'%' -f2-)"; \ + push_opts="${push_opts:+"%${push_opts}"}"; \ + remote="$(git remote-for-branch "${branch}")"; \ + git push "${remote}" "HEAD:refs/for/${branch}${push_opts}"; \ +};f" +psfor = "!f() { \ + set -ex; \ + git caane; \ + git pfor "$@"; \ +};f"