git: sshifyPushUrl

main
Zynh Ludwig 2024-07-28 18:29:36 -07:00
parent ab53ebc1db
commit 1874ab5f29
1 changed files with 17 additions and 0 deletions

View File

@ -4,6 +4,18 @@ let
cfg = config.snowhawk.git; cfg = config.snowhawk.git;
macos = config.snowhawk.macos.enable; macos = config.snowhawk.macos.enable;
sops = config.snowhawk.sops.enable; sops = config.snowhawk.sops.enable;
sshifyPushUrl =
let
urlParser = "${pkgs.url-parser}/bin/url-parser";
git = "${pkgs.git}/bin/git";
cut = "${pkgs.coreutils}/bin/cut";
in
pkgs.writeShellScriptBin "sshify-push-url" ''
base=$(${urlParser} --url $(${git} remote get-url origin) host)
path=$(${urlParser} --url $(${git} remote get-url origin) path | ${cut} -b 2-)
echo "$base:$path"
'';
in in
{ {
options.snowhawk.git = { options.snowhawk.git = {
@ -36,6 +48,11 @@ in
dump = "cat-file -p"; dump = "cat-file -p";
graph = "log --graph --decorate --pretty=oneline --abbrev-commit"; graph = "log --graph --decorate --pretty=oneline --abbrev-commit";
# Convert pull url into ssh push url
sshify-push-url = ''
!${pkgs.bash}/bin/bash -c "git remote set-url --push origin $(${sshifyPushUrl}/bin/sshify-push-url)"
'';
# local patch-wise ignore workflow # local patch-wise ignore workflow
unchanged = "update-index --assume-unchanged"; unchanged = "update-index --assume-unchanged";
changed = "update-index --no-assume-unchanged"; changed = "update-index --no-assume-unchanged";