Skip to content

Commit

Permalink
Use git credential manager in Ubuntu Server (#237)
Browse files Browse the repository at this point in the history
* use `git-credential-manager` in Ubuntu Server

* add test
  • Loading branch information
shunk031 authored Oct 24, 2024
1 parent 386b37e commit a342a98
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{ if eq .chezmoi.os "linux" -}}
{{ if eq .chezmoi.osRelease.idLike "debian" -}}
{{ if eq .system "server" -}}
{{ include "../install/ubuntu/server/git_credential_manager.sh" }}
{{ end -}}
{{ end -}}
{{ end -}}
11 changes: 4 additions & 7 deletions home/dot_config/git/config.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,23 @@
name = Shunsuke KITADA
email = {{ .email | quote }}
signingkey = D55D775A7951407C

[color]
ui = auto

[url "git@github.com:"]
pushinsteadof = https://github.com/

[pager]
branch = cat
config = cat

[ghq]
root = ~/.local/share
root = ~/ghq

[commit]
gpgsign = true

[pull]
rebase = false

[core]
quotepath = false
{{ if eq .chezmoi.os "linux" -}}
[credential]
credentialStore = cache
{{ end -}}
29 changes: 29 additions & 0 deletions install/ubuntu/server/git_credential_manager.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

set -Eeuo pipefail

if [ "${DOTFILES_DEBUG:-}" ]; then
set -x
fi

function install_git_credential_manager() {
local gcm_version="2.6.0"
local gcm_deb="gcm-linux_amd64.${gcm_version}.deb"
wget "https://github.com/git-ecosystem/git-credential-manager/releases/download/v${gcm_version}/${gcm_deb}"
sudo dpkg -i ${gcm_deb}
rm -v ${gcm_deb}
git-credential-manager configure
}

function uninstall_git_credential_manager() {
git-credential-manager unconfigure
sudo dpkg -r gcm
}

function main() {
install_git_credential_manager
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
main
fi
17 changes: 17 additions & 0 deletions tests/install/ubuntu/server/git_credential_manager.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bats

readonly SCRIPT_PATH="./install/ubuntu/server/git_credential_manager.sh"

function setup() {
source "${SCRIPT_PATH}"
}

function teardown() {
run uninstall_git_credential_manager
}

@test "[ubuntu-server] starship" {
DOTFILES_DEBUG=1 bash "${SCRIPT_PATH}"

[ -x "$(command -v git-credential-manager)" ]
}

1 comment on commit a342a98

@shunk031
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'MacOS benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: a342a98 Previous: 386b37e Ratio
zsh average startup time 0.305 Second 0.155 Second 1.97
zsh initial startup time 1.67 Second 0.83 Second 2.01

This comment was automatically generated by workflow using github-action-benchmark.

CC: @shunk031

Please sign in to comment.