summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/git-preview.nix
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2017-10-01 17:54:06 +0200
committerlassulus <lassulus@lassul.us>2017-10-01 17:54:06 +0200
commitd7f65ea679866f24e4ca52b51bd6f068a6b38195 (patch)
tree6a09e7cc2a4c9af0507bdc189652c78832a2f952 /krebs/5pkgs/simple/git-preview.nix
parentd973c779eb71749af464edb1ed0216b0d5317eb2 (diff)
parente62f376e6177f3efb0e0bcd3aad97a991c3b6d60 (diff)
Merge branch 'master' into staging/17.09
Diffstat (limited to 'krebs/5pkgs/simple/git-preview.nix')
-rw-r--r--krebs/5pkgs/simple/git-preview.nix17
1 files changed, 17 insertions, 0 deletions
diff --git a/krebs/5pkgs/simple/git-preview.nix b/krebs/5pkgs/simple/git-preview.nix
new file mode 100644
index 000000000..d6c9579a7
--- /dev/null
+++ b/krebs/5pkgs/simple/git-preview.nix
@@ -0,0 +1,17 @@
+{ coreutils, git, writeDashBin }:
+
+writeDashBin "git-preview" ''
+ set -efu
+ head_commit=$(${git}/bin/git log -1 --format=%H)
+ merge_commit=$1; shift
+ merge_message='Merge for git-preview'
+ preview_dir=$(${coreutils}/bin/mktemp --tmpdir -d git-preview.XXXXXXXX)
+ preview_branch=$(${coreutils}/bin/basename "$preview_dir")
+ ${git}/bin/git worktree add -b "$preview_branch" "$preview_dir" >/dev/null
+ ${git}/bin/git -C "$preview_dir" checkout "$head_commit"
+ ${git}/bin/git -C "$preview_dir" merge -m "$merge_message" "$merge_commit"
+ ${git}/bin/git -C "$preview_dir" diff "$head_commit.." "$@" &
+ ${git}/bin/git branch -fd "$preview_branch"
+ ${coreutils}/bin/rm -fR "$preview_dir"
+ wait
+''