summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2012-09-10 12:03:31 +0100
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2012-09-10 12:03:31 +0100
commit1a6a09f604441cc2322903b9a1cba4f3564c68a2 (patch)
tree48b7eec38303f8ac8cab00cb666f4e9952c44095
parent57f53edd217b06031cfa003c620b553292ebd5e7 (diff)
downloadtrove-setup-1a6a09f604441cc2322903b9a1cba4f3564c68a2.tar.gz
Update post-receive hook for better Mason integration
-rw-r--r--gitano-admin/global-hooks/post-receive.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/gitano-admin/global-hooks/post-receive.lua b/gitano-admin/global-hooks/post-receive.lua
index bb23ec4..679cfa8 100644
--- a/gitano-admin/global-hooks/post-receive.lua
+++ b/gitano-admin/global-hooks/post-receive.lua
@@ -12,6 +12,8 @@
local project_hook, repo, updates = ...
+local EMPTY_SHA = ("0"):rep(40)
+
local masonhost = "##MASON_HOST##:##MASON_PORT##"
local basepath = "/1.0"
local urlbases = {
@@ -56,8 +58,17 @@ if notify_mason and repo.name ~= "gitano-admin" then
local toreport = {}
for ref, info in pairs(updates) do
if not ref:match("^refs/gitano") then
+ local action
+ if info.oldsha == EMPTY_SHA then
+ action = "create"
+ elseif info.newsha == EMPTY_SHA then
+ action = "delete"
+ else
+ action = "update"
+ end
toreport[#toreport+1] = {
('"ref": %q,'):format(ref),
+ ('"action": %q,'):format(action),
('"old": %q,'):format(info.oldsha),
('"new": %q'):format(info.newsha)
}