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 {
|
config = lib.mkIf config.programs.git.enable {
|
||||||
home.packages = [
|
home.packages = [
|
||||||
(pkgs.writeShellApplication {
|
(pkgs.writeShellApplication {
|
||||||
name = "git-sync-init";
|
name = "git-sync";
|
||||||
text = (lib.strings.concatLines
|
text = (lib.strings.concatLines
|
||||||
(map (r: ''[ -d "${r.path}" ] || ${pkgs.git}/bin/git clone "${r.uri}" "${r.path}"'')
|
(map
|
||||||
(lib.attrsets.attrValues config.services.git-sync.repositories)
|
(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
|
||||||
})
|
'')
|
||||||
(pkgs.writeShellApplication {
|
|
||||||
name = "git-sync-pull";
|
|
||||||
text = (lib.strings.concatLines
|
|
||||||
(map (r: ''(cd "${r.path}"; echo "$PWD"; ${pkgs.git}/bin/git pull || true)'')
|
|
||||||
(lib.attrsets.attrValues config.services.git-sync.repositories)
|
(lib.attrsets.attrValues config.services.git-sync.repositories)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue