irc-announce: allow disabling just log and diff

This commit is contained in:
tv 2015-10-01 20:33:18 +02:00
parent cf80bdaf42
commit 4d1aebc740
2 changed files with 15 additions and 14 deletions

View File

@ -58,12 +58,13 @@ let
make-public-repo = name: { desc ? null, ... }: { make-public-repo = name: { desc ? null, ... }: {
inherit name desc; inherit name desc;
public = true; public = true;
hooks = optionalAttrs (config.krebs.build.host.name == "cd") { hooks = {
post-receive = git.irc-announce { post-receive = git.irc-announce {
# TODO make nick = config.krebs.build.host.name the default # TODO make nick = config.krebs.build.host.name the default
nick = config.krebs.build.host.name; nick = config.krebs.build.host.name;
channel = "#retiolum"; channel = "#retiolum";
server = "cd.retiolum"; server = "cd.retiolum";
verbose = config.krebs.build.host.name == "cd";
}; };
}; };
}; };

View File

@ -1,7 +1,7 @@
{ lib, pkgs, ... }: { lib, pkgs, ... }:
let let
inherit (lib) addNames escapeShellArg makeSearchPath; inherit (lib) addNames escapeShellArg makeSearchPath optionalString;
commands = addNames { commands = addNames {
git-receive-pack = {}; git-receive-pack = {};
@ -104,7 +104,7 @@ let
hooks = { hooks = {
# TODO make this a package? # TODO make this a package?
irc-announce = { nick, channel, server, port ? 6667 }: '' irc-announce = { nick, channel, server, port ? 6667, verbose ? false }: ''
#! /bin/sh #! /bin/sh
set -euf set -euf
@ -150,7 +150,7 @@ let
h=$(echo $ref | sed 's:^refs/heads/::') h=$(echo $ref | sed 's:^refs/heads/::')
# empty_tree=$(git hash-object -t tree /dev/null # empty_tree=$(git hash-object -t tree /dev/null)
empty_tree=4b825dc6 empty_tree=4b825dc6
id=$(echo $newrev | cut -b-7) id=$(echo $newrev | cut -b-7)
@ -160,11 +160,9 @@ let
case $receive_mode in case $receive_mode in
create) create)
#git log --oneline $id2
link="$cgit_endpoint/$GIT_SSH_REPO/?h=$h" link="$cgit_endpoint/$GIT_SSH_REPO/?h=$h"
;; ;;
delete) delete)
#git log --oneline $id2
link="$cgit_endpoint/$GIT_SSH_REPO/ ($h)" link="$cgit_endpoint/$GIT_SSH_REPO/ ($h)"
;; ;;
fast-forward|non-fast-forward) fast-forward|non-fast-forward)
@ -175,15 +173,17 @@ let
#$host $GIT_SSH_REPO $ref $link #$host $GIT_SSH_REPO $ref $link
add_message $(pink push) $link $(gray "($receive_mode)") add_message $(pink push) $link $(gray "($receive_mode)")
add_message "$( ${optionalString verbose ''
git log \ add_message "$(
--format="$(orange %h) %s $(gray '(%ar)')" \ git log \
--reverse \ --format="$(orange %h) %s $(gray '(%ar)')" \
$id2..$id --reverse \
$id2..$id
git diff --stat $id2..$id \ git diff --stat $id2..$id \
| sed '$!s/\(+*\)\(-*\)$/'$(green '\1')$(red '\2')'/' | sed '$!s/\(+*\)\(-*\)$/'$(green '\1')$(red '\2')'/'
)" )"
''}
done done