summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/git-preview.nix
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2017-09-30 16:12:08 +0200
committerlassulus <lassulus@lassul.us>2017-09-30 16:12:08 +0200
commit1a5d6a75b0f84e8bacbe24f205198918946061a7 (patch)
tree71cc0f7538a6d0b2869331000c946c7d7e8e557f /krebs/5pkgs/simple/git-preview.nix
parent6d083f03b76f6dfbe1810f8408301d0c916c3b34 (diff)
parentbbced2ea622d97aa14f8b9bf6a75748d7d51da53 (diff)
Merge remote-tracking branch 'ni/master'
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
+''