diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2017-10-11 15:23:04 +0200 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2017-10-11 15:23:04 +0200 |
| commit | efaf7e9a8804c9f376bacf9fb64ecdb4dc108168 (patch) | |
| tree | e22df15afba58f99d8a5e79a6d553fcd8566f682 | |
| parent | cbfd5d09616e7af39cdb8c8b685fdd24f8783fe9 (diff) | |
| download | nixos-efaf7e9a8804c9f376bacf9fb64ecdb4dc108168.tar nixos-efaf7e9a8804c9f376bacf9fb64ecdb4dc108168.tar.gz nixos-efaf7e9a8804c9f376bacf9fb64ecdb4dc108168.tar.bz2 nixos-efaf7e9a8804c9f376bacf9fb64ecdb4dc108168.tar.xz nixos-efaf7e9a8804c9f376bacf9fb64ecdb4dc108168.zip | |
git-sync in /nix/store
| -rw-r--r-- | ymir.nix | 23 |
1 files changed, 22 insertions, 1 deletions
| @@ -891,7 +891,28 @@ in rec { | |||
| 891 | [directory-sync] | 891 | [directory-sync] |
| 892 | directory=/var/lib/infinoted/dirsync | 892 | directory=/var/lib/infinoted/dirsync |
| 893 | interval=5 | 893 | interval=5 |
| 894 | hook=/var/lib/infinoted/git-sync.sh | 894 | hook=${pkgs.writeScript "git-sync.sh" '' |
| 895 | #!${pkgs.zsh}/bin/zsh | ||
| 896 | |||
| 897 | repository=$(git -C ${2:h} rev-parse --show-toplevel) | ||
| 898 | [[ $? -eq 0 ]] || exit 0 | ||
| 899 | |||
| 900 | git() { | ||
| 901 | $(whence -cp git) -C ${repository} ${@} | ||
| 902 | } | ||
| 903 | |||
| 904 | typeset -a changeSet | ||
| 905 | changeSet=() | ||
| 906 | git diff -z --name-only | \ | ||
| 907 | while IFS= read -r -d $'\0' change; do changeSet=(${changeSet} ${change}); done | ||
| 908 | |||
| 909 | [[ ${changeSet[(i)$(realpath ${2} --relative-to=${repository})]} -le ${#changeSet} ]] || exit 0 | ||
| 910 | |||
| 911 | commitMessage=$(printf "%s modified via infinoted" $(realpath ${2} --relative-to=${repository})) | ||
| 912 | git add ${2} | ||
| 913 | git commit -m ${commitMessage} --no-edit ${2} | ||
| 914 | git push | ||
| 915 | ''} | ||
| 895 | ''; | 916 | ''; |
| 896 | }; | 917 | }; |
| 897 | 918 | ||
