summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/git-preview/default.nix
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2017-09-21 23:36:34 +0200
committerlassulus <lassulus@lassul.us>2017-09-22 00:33:46 +0200
commit457f2f134587e10e386fb76e9d8c571dfe4490ec (patch)
tree0b7b4b71c71146bdc77b2d37747fc980e5fd02c0 /krebs/5pkgs/simple/git-preview/default.nix
parent0075549f344aba535797f26c9fb1e805065973f7 (diff)
git-preview: init
Diffstat (limited to 'krebs/5pkgs/simple/git-preview/default.nix')
-rw-r--r--krebs/5pkgs/simple/git-preview/default.nix15
1 files changed, 15 insertions, 0 deletions
diff --git a/krebs/5pkgs/simple/git-preview/default.nix b/krebs/5pkgs/simple/git-preview/default.nix
new file mode 100644
index 000000000..f20f2a636
--- /dev/null
+++ b/krebs/5pkgs/simple/git-preview/default.nix
@@ -0,0 +1,15 @@
+{ coreutils, git, stdenv, writeDashBin }:
+
+writeDashBin "git-preview" ''
+ PATH=${stdenv.lib.makeBinPath [
+ coreutils
+ git
+ ]}''${PATH+:$PATH}
+ hashes=$(git log --format=%h "..$1")
+ end=$(echo "$hashes" | head -1)
+ start=$(echo "$hashes" | tail -1)
+ # exit if no diff was found
+ test -z "$start" && exit 0
+ shift
+ git diff "$start^..$end" "$@"
+''