From cf80bdaf425c9757cf15496c62048125b1a2c822 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 1 Oct 2015 20:04:56 +0200 Subject: tv git: announce only via cd --- tv/2configs/git.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tv') diff --git a/tv/2configs/git.nix b/tv/2configs/git.nix index 5f5fae483..da9f70629 100644 --- a/tv/2configs/git.nix +++ b/tv/2configs/git.nix @@ -58,7 +58,7 @@ let make-public-repo = name: { desc ? null, ... }: { inherit name desc; public = true; - hooks = { + hooks = optionalAttrs (config.krebs.build.host.name == "cd") { post-receive = git.irc-announce { # TODO make nick = config.krebs.build.host.name the default nick = config.krebs.build.host.name; -- cgit v1.2.3 From 4d1aebc740ffc35f97060c60e43300b9d60b5229 Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 1 Oct 2015 20:33:18 +0200 Subject: irc-announce: allow disabling just log and diff --- tv/2configs/git.nix | 3 ++- tv/4lib/git.nix | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) (limited to 'tv') diff --git a/tv/2configs/git.nix b/tv/2configs/git.nix index da9f70629..401cf5f4d 100644 --- a/tv/2configs/git.nix +++ b/tv/2configs/git.nix @@ -58,12 +58,13 @@ let make-public-repo = name: { desc ? null, ... }: { inherit name desc; public = true; - hooks = optionalAttrs (config.krebs.build.host.name == "cd") { + hooks = { post-receive = git.irc-announce { # TODO make nick = config.krebs.build.host.name the default nick = config.krebs.build.host.name; channel = "#retiolum"; server = "cd.retiolum"; + verbose = config.krebs.build.host.name == "cd"; }; }; }; diff --git a/tv/4lib/git.nix b/tv/4lib/git.nix index 748b77269..d8827115a 100644 --- a/tv/4lib/git.nix +++ b/tv/4lib/git.nix @@ -1,7 +1,7 @@ { lib, pkgs, ... }: let - inherit (lib) addNames escapeShellArg makeSearchPath; + inherit (lib) addNames escapeShellArg makeSearchPath optionalString; commands = addNames { git-receive-pack = {}; @@ -104,7 +104,7 @@ let hooks = { # TODO make this a package? - irc-announce = { nick, channel, server, port ? 6667 }: '' + irc-announce = { nick, channel, server, port ? 6667, verbose ? false }: '' #! /bin/sh set -euf @@ -150,7 +150,7 @@ let 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 id=$(echo $newrev | cut -b-7) @@ -160,11 +160,9 @@ let case $receive_mode in create) - #git log --oneline $id2 link="$cgit_endpoint/$GIT_SSH_REPO/?h=$h" ;; delete) - #git log --oneline $id2 link="$cgit_endpoint/$GIT_SSH_REPO/ ($h)" ;; fast-forward|non-fast-forward) @@ -175,15 +173,17 @@ let #$host $GIT_SSH_REPO $ref $link add_message $(pink push) $link $(gray "($receive_mode)") - add_message "$( - git log \ - --format="$(orange %h) %s $(gray '(%ar)')" \ - --reverse \ - $id2..$id - - git diff --stat $id2..$id \ - | sed '$!s/\(+*\)\(-*\)$/'$(green '\1')$(red '\2')'/' - )" + ${optionalString verbose '' + add_message "$( + git log \ + --format="$(orange %h) %s $(gray '(%ar)')" \ + --reverse \ + $id2..$id + + git diff --stat $id2..$id \ + | sed '$!s/\(+*\)\(-*\)$/'$(green '\1')$(red '\2')'/' + )" + ''} done -- cgit v1.2.3