git-sync: Replace with git-sync
This commit is contained in:
parent
f83806a307
commit
033f411060
|
@ -3,17 +3,23 @@
|
|||
config = lib.mkIf config.programs.git.enable {
|
||||
home.packages = [
|
||||
(pkgs.writeShellApplication {
|
||||
name = "git-sync-init";
|
||||
name = "git-sync";
|
||||
text = (lib.strings.concatLines
|
||||
(map (r: ''[ -d "${r.path}" ] || ${pkgs.git}/bin/git clone "${r.uri}" "${r.path}"'')
|
||||
(lib.attrsets.attrValues config.services.git-sync.repositories)
|
||||
)
|
||||
);
|
||||
})
|
||||
(pkgs.writeShellApplication {
|
||||
name = "git-sync-pull";
|
||||
text = (lib.strings.concatLines
|
||||
(map (r: ''(cd "${r.path}"; echo "$PWD"; ${pkgs.git}/bin/git pull || true)'')
|
||||
(map
|
||||
(r: ''
|
||||
echo "===== ${r.path}"
|
||||
if [ ! -d "${r.path}" ]
|
||||
then
|
||||
${pkgs.git}/bin/git clone "${r.uri}" "${r.path}"
|
||||
else
|
||||
(
|
||||
cd "${r.path}"
|
||||
${pkgs.git}/bin/git diff --quiet || echo "Repository is dirty!"
|
||||
${pkgs.git}/bin/git pull || true
|
||||
${pkgs.git}/bin/git push || true
|
||||
)
|
||||
fi
|
||||
'')
|
||||
(lib.attrsets.attrValues config.services.git-sync.repositories)
|
||||
)
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue