irc-announce: whitelist refs instead of branches
This commit is contained in:
parent
db5921f163
commit
aa04423e3a
@ -16,14 +16,14 @@ let
|
|||||||
cgit.section = section;
|
cgit.section = section;
|
||||||
hooks = mkDefault {
|
hooks = mkDefault {
|
||||||
post-receive = pkgs.git-hooks.irc-announce {
|
post-receive = pkgs.git-hooks.irc-announce {
|
||||||
nick = config.networking.hostName;
|
|
||||||
verbose = false;
|
|
||||||
channel = "#xxx";
|
channel = "#xxx";
|
||||||
server = "irc.r";
|
refs = [
|
||||||
branches = [
|
"refs/heads/master"
|
||||||
"master"
|
"refs/heads/newest"
|
||||||
"newest"
|
|
||||||
];
|
];
|
||||||
|
nick = config.networking.hostName;
|
||||||
|
server = "irc.r";
|
||||||
|
verbose = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -6,11 +6,11 @@ with import <stockholm/lib>;
|
|||||||
# TODO irc-announce should return a derivation
|
# TODO irc-announce should return a derivation
|
||||||
# but it cannot because krebs.git.repos.*.hooks :: attrsOf str
|
# but it cannot because krebs.git.repos.*.hooks :: attrsOf str
|
||||||
irc-announce =
|
irc-announce =
|
||||||
{ branches ? []
|
{ cgit_endpoint ? "http://cgit.${nick}.r"
|
||||||
, cgit_endpoint ? "http://cgit.${nick}.r"
|
|
||||||
, channel
|
, channel
|
||||||
, nick
|
, nick
|
||||||
, port ? 6667
|
, port ? 6667
|
||||||
|
, refs ? []
|
||||||
, server
|
, server
|
||||||
, verbose ? false
|
, verbose ? false
|
||||||
}: /* sh */ ''
|
}: /* sh */ ''
|
||||||
@ -57,14 +57,15 @@ with import <stockholm/lib>;
|
|||||||
receive_mode=non-fast-forward
|
receive_mode=non-fast-forward
|
||||||
fi
|
fi
|
||||||
|
|
||||||
h=$(echo $ref | sed 's:^refs/heads/::')
|
${optionalString (refs != []) ''
|
||||||
|
if ! { echo "$ref" | grep -qE "${concatStringsSep "|" refs}"; }; then
|
||||||
${optionalString (branches != []) ''
|
echo "we are not announcing this ref: $h"
|
||||||
if ! (echo "$h" | grep -qE "${concatStringsSep "|" branches}"); then
|
|
||||||
echo "we are not serving this branch: $h"
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
''}
|
''}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
@ -100,10 +100,12 @@ let
|
|||||||
# 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 = "#xxx";
|
channel = "#xxx";
|
||||||
|
# TODO define refs in some kind of option per repo
|
||||||
|
refs = [
|
||||||
|
"refs/heads/master"
|
||||||
|
];
|
||||||
server = "irc.r";
|
server = "irc.r";
|
||||||
verbose = config.krebs.build.host.name == "prism";
|
verbose = config.krebs.build.host.name == "prism";
|
||||||
# TODO define branches in some kind of option per repo
|
|
||||||
branches = [ "master" ];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -121,10 +123,13 @@ let
|
|||||||
# 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 = "#xxx";
|
channel = "#xxx";
|
||||||
|
# TODO define refs in some kind of option per repo
|
||||||
|
refs = [
|
||||||
|
"refs/heads/master"
|
||||||
|
"refs/heads/staging*"
|
||||||
|
];
|
||||||
server = "irc.r";
|
server = "irc.r";
|
||||||
verbose = false;
|
verbose = false;
|
||||||
# TODO define branches in some kind of option per repo
|
|
||||||
branches = [ "master" "staging*" ];
|
|
||||||
};
|
};
|
||||||
} // hooks;
|
} // hooks;
|
||||||
};
|
};
|
||||||
|
@ -14,10 +14,12 @@ let
|
|||||||
hooks = mkIf announce (mkDefault {
|
hooks = mkIf announce (mkDefault {
|
||||||
post-receive = pkgs.git-hooks.irc-announce {
|
post-receive = pkgs.git-hooks.irc-announce {
|
||||||
nick = config.networking.hostName;
|
nick = config.networking.hostName;
|
||||||
verbose = false;
|
|
||||||
channel = "#xxx";
|
channel = "#xxx";
|
||||||
|
refs = [
|
||||||
|
"refs/heads/newest"
|
||||||
|
];
|
||||||
server = "irc.r";
|
server = "irc.r";
|
||||||
branches = [ "newest" ];
|
verbose = false;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user