From 1a6a09f604441cc2322903b9a1cba4f3564c68a2 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Mon, 10 Sep 2012 12:03:31 +0100 Subject: Update post-receive hook for better Mason integration --- gitano-admin/global-hooks/post-receive.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) 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) } -- cgit v1.2.1