summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/git-hooks/default.nix
diff options
context:
space:
mode:
authorlassulus <lass@lassul.us>2017-06-20 16:05:27 +0200
committerlassulus <lass@lassul.us>2017-06-20 16:05:27 +0200
commitf0bcc6e1f147726cbbf8c3d8a9da503886d2321d (patch)
treebf8e0eabe03a8dcf9201c580ab1f4ecc4660b8b4 /krebs/5pkgs/simple/git-hooks/default.nix
parentbda14221cf46003ecf76756a5db7422c70737c85 (diff)
parent57c6b890f9088bb333eeab215ecfeca9d09ce3ef (diff)
Merge remote-tracking branch 'ni/master' into HEAD
Diffstat (limited to 'krebs/5pkgs/simple/git-hooks/default.nix')
-rw-r--r--krebs/5pkgs/simple/git-hooks/default.nix40
1 files changed, 26 insertions, 14 deletions
diff --git a/krebs/5pkgs/simple/git-hooks/default.nix b/krebs/5pkgs/simple/git-hooks/default.nix
index 4017b873b..1930c7f14 100644
--- a/krebs/5pkgs/simple/git-hooks/default.nix
+++ b/krebs/5pkgs/simple/git-hooks/default.nix
@@ -5,7 +5,15 @@ with import <stockholm/lib>;
{
# TODO irc-announce should return a derivation
# but it cannot because krebs.git.repos.*.hooks :: attrsOf str
- irc-announce = { nick, channel, server, port ? 6667, verbose ? false, branches ? [] }: ''
+ irc-announce =
+ { branches ? []
+ , cgit_endpoint ? "http://cgit.${nick}.r"
+ , channel
+ , nick
+ , port ? 6667
+ , server
+ , verbose ? false
+ }: /* sh */ ''
#! /bin/sh
set -euf
@@ -34,7 +42,6 @@ with import <stockholm/lib>;
port=${toString port}
host=$nick
- cgit_endpoint=http://cgit.$host.r
empty=0000000000000000000000000000000000000000
@@ -66,22 +73,27 @@ with import <stockholm/lib>;
if [ $newrev = $empty ]; then id=$empty_tree; fi
if [ $oldrev = $empty ]; then id2=$empty_tree; fi
- case $receive_mode in
- create)
- link="$cgit_endpoint/$GIT_SSH_REPO/?h=$h"
- ;;
- delete)
- link="$cgit_endpoint/$GIT_SSH_REPO/ ($h)"
- ;;
- fast-forward|non-fast-forward)
- link="$cgit_endpoint/$GIT_SSH_REPO/diff/?h=$h&id=$id&id2=$id2"
- ;;
- esac
+ ${if cgit_endpoint != null then /* sh */ ''
+ cgit_endpoint=${escapeShellArg cgit_endpoint}
+ case $receive_mode in
+ create)
+ link="$cgit_endpoint/$GIT_SSH_REPO/?h=$h"
+ ;;
+ delete)
+ link="$cgit_endpoint/$GIT_SSH_REPO/ ($h)"
+ ;;
+ fast-forward|non-fast-forward)
+ link="$cgit_endpoint/$GIT_SSH_REPO/diff/?h=$h&id=$id&id2=$id2"
+ ;;
+ esac
+ '' else /* sh */ ''
+ link="$GIT_SSH_REPO $h"
+ ''}
#$host $GIT_SSH_REPO $ref $link
add_message $(pink push) $link $(gray "($receive_mode)")
- ${optionalString verbose ''
+ ${optionalString verbose /* sh */ ''
add_message "$(
git log \
--format="$(orange %h) %s $(gray '(%ar)')" \