From fe9e2e1b8a8ead27cd933b6a1a3613be0eaddb26 Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Sun, 16 Jul 2023 14:17:30 -0300 Subject: [PATCH] Setup git-lfs --- home/dot_gitconfig.tmpl | 81 +++++++++++++++++++++----------------- root/.chezmoiexternal.yaml | 8 ++++ root/etc/gitconfig.tmpl | 14 +++++-- 3 files changed, 62 insertions(+), 41 deletions(-) diff --git a/home/dot_gitconfig.tmpl b/home/dot_gitconfig.tmpl index 8fa6646e..6fec2d09 100644 --- a/home/dot_gitconfig.tmpl +++ b/home/dot_gitconfig.tmpl @@ -1,42 +1,49 @@ [user] - name = {{ .name }} - email = {{ .email }} +name = {{ .name }} +email = {{ .email }} + [core] - editor = {{ .editor }} -[rebase] - autoStash = true -[merge] - autoStash = true -[push] - autoSetupRemote = true -[diff] - tool = vscode +editor = {{ .editor }} + [difftool "vscode"] - cmd = code --wait --diff $LOCAL $REMOTE -[merge] - tool = vscode +cmd = code --wait --diff $LOCAL $REMOTE + [mergetool "vscode"] - cmd = code --wait $MERGED +cmd = code --wait $MERGED + +[diff] +tool = vscode + +[merge] +autoStash = true +tool = vscode + +[rebase] +autoStash = true + +[push] +autoSetupRemote = true + [alias] - s = status - c = commit - ca = commit --amend - caa = ca -a - cane = ca --no-edit - caane = cane -a - co = checkout - cob = checkout -b - cp = cherry-pick - get-default-branch = "!f() { set -ex; remote="${1:-"origin"}"; git ls-remote --symref "${remote}" HEAD | sed -n 's,^ref: refs/heads/\\(\\S*\\)\\tHEAD$,\\1,p'; }; f" - fully-clean = "!f() {set -ex; default_branch="$(git get-default-branch)"; git checkout "${default_branch}"; git fetch origin "${default_branch}"; git clean -fdx; }; f" - get-current-branch = "!git branch --show-current | grep ." - get-remote-for-branch = "!f() { set -ex; branch="${1:-"$(git get-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 get-current-branch)"}"; remote="$(git get-remote-for-branch "${branch}")"; git reset --hard "${remote}/$branch"; }; f" - pfor = "!f() { set -ex; branch="${1:-"$(git get-current-branch)"}"; remote="$(git get-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 get-current-branch)"}"; remote="$(git get-remote-for-branch "${branch}")"; git push "${remote}" "HEAD:refs/drafts/${branch}"; }; f" - psdraft = "!f() { set -ex; git caane; git pdraft "$@"; }; f" - plr = pull --rebase - prune-refs = fetch --prune --prune-tags - hist = log --pretty=format:'%C(yellow)%h%Creset %ad | %s%d %Cgreen[%an]%Creset' --graph --date=short - apply-gitignore = "!f() { set -ex; git rm -r --cached . >/dev/null; git add .; }; f" +s = status +c = commit +ca = commit --amend +caa = ca -a +cane = ca --no-edit +caane = cane -a +co = checkout +cob = checkout -b +cp = cherry-pick +get-default-branch = "!f() { set -ex; remote="${1:-"origin"}"; git ls-remote --symref "${remote}" HEAD | sed -n 's,^ref: refs/heads/\\(\\S*\\)\\tHEAD$,\\1,p'; }; f" +fully-clean = "!f() {set -ex; default_branch="$(git get-default-branch)"; git checkout "${default_branch}"; git fetch origin "${default_branch}"; git clean -fdx; }; f" +get-current-branch = "!git branch --show-current | grep ." +get-remote-for-branch = "!f() { set -ex; branch="${1:-"$(git get-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 get-current-branch)"}"; remote="$(git get-remote-for-branch "${branch}")"; git reset --hard "${remote}/$branch"; }; f" +pfor = "!f() { set -ex; branch="${1:-"$(git get-current-branch)"}"; remote="$(git get-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 get-current-branch)"}"; remote="$(git get-remote-for-branch "${branch}")"; git push "${remote}" "HEAD:refs/drafts/${branch}"; }; f" +psdraft = "!f() { set -ex; git caane; git pdraft "$@"; }; f" +plr = pull --rebase +prune-refs = fetch --prune --prune-tags +hist = log --pretty=format:'%C(yellow)%h%Creset %ad | %s%d %Cgreen[%an]%Creset' --graph --date=short +apply-gitignore = "!f() { set -ex; git rm -r --cached . >/dev/null; git add .; }; f" diff --git a/root/.chezmoiexternal.yaml b/root/.chezmoiexternal.yaml index 6ce40de1..604d0203 100644 --- a/root/.chezmoiexternal.yaml +++ b/root/.chezmoiexternal.yaml @@ -38,6 +38,14 @@ url: "https://github.com/docker/compose-switch/releases/download/v{{ template "get-github-latest-version" list "docker/compose-switch" $cache }}/docker-compose-linux-{{ .chezmoi.arch }}" executable: true +"usr/local/bin/git-lfs": + type: file + url: "https://github.com/git-lfs/git-lfs/releases/download/v{{ template "get-github-latest-version" list "git-lfs/git-lfs" $cache }}/git-lfs-linux-{{ .chezmoi.arch }}-v{{ template "get-github-latest-version" list "git-lfs/git-lfs" $cache }}.tar.gz" + filter: + command: tar + args: ["-x", "-z", "-O", "git-lfs-{{ template "get-github-latest-version" list "git-lfs/git-lfs" $cache }}/git-lfs"] + executable: true + {{ if .is_wsl }} "usr/bin/docker-credential-wincred.exe": type: file diff --git a/root/etc/gitconfig.tmpl b/root/etc/gitconfig.tmpl index 497ebce4..d88e9cd5 100644 --- a/root/etc/gitconfig.tmpl +++ b/root/etc/gitconfig.tmpl @@ -1,9 +1,15 @@ [credential] helper = /usr/local/bin/git-credential-manager -{{ if .is_wsl -}} +{{- if .is_wsl }} credentialStore = wincredman -{{ else if and .is_gnome (not .is_headless) -}} +{{- else if and .is_gnome (not .is_headless) }} credentialStore = secretservice -{{ else -}} +{{- else }} credentialStore = plaintext -{{ end -}} +{{- end }} + +[filter "lfs"] +clean = git-lfs clean -- %f +smudge = git-lfs smudge -- %f +process = git-lfs filter-process +required = true