summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@gmail.com>2017-08-01 16:22:09 +0100
committerRichard Maw <richard.maw@gmail.com>2017-08-01 16:22:09 +0100
commitea45bb9535fceea9c9feebde0360c594fc985fe1 (patch)
tree5ab3d6ebc1b2efe5cac2020cd9e089570245d361
parenta44c0319c286c526f489122b785c89bbf5845782 (diff)
downloadgitano-ea45bb9535fceea9c9feebde0360c594fc985fe1.tar.gz
Move post-push dangling-HEAD check to post-receive hook
The smart-http interface starts http-backend which calls receive-pack. Unfortunately we were performing the dangling-HEAD check after calling receive-pack ourselves, so when using smart-http we weren't performing the check. By moving this into the post-receive hook the check can be performed in smart-http too.
-rw-r--r--bin/gitano-post-receive-hook.in11
-rw-r--r--lib/gitano/command.lua9
2 files changed, 12 insertions, 8 deletions
diff --git a/bin/gitano-post-receive-hook.in b/bin/gitano-post-receive-hook.in
index cb77e06..61df35c 100644
--- a/bin/gitano-post-receive-hook.in
+++ b/bin/gitano-post-receive-hook.in
@@ -213,9 +213,20 @@ function post_receive_run_supple(repo, updates)
return "continue"
end
+function post_receive_check_head(repo, updates)
+ -- Check that HEAD is now resolvable in the repo
+ if not repo.git:get("HEAD") then
+ gitano.log.warn("")
+ gitano.log.warn(gitano.i18n.expand("WARN_HEAD_DANGLING"))
+ gitano.log.warn("")
+ end
+ return "continue"
+end
+
gitano.hooks.add(gitano.hooks.names.POST_RECEIVE, -1000,
post_receive_core_handler)
gitano.hooks.add(gitano.hooks.names.POST_RECEIVE, 0, post_receive_run_supple)
+gitano.hooks.add(gitano.hooks.names.POST_RECEIVE, 1000, post_receive_check_head)
gitano.hooks.run(gitano.hooks.names.POST_RECEIVE, repo, updates)
diff --git a/lib/gitano/command.lua b/lib/gitano/command.lua
index 3f433ca..317d32a 100644
--- a/lib/gitano/command.lua
+++ b/lib/gitano/command.lua
@@ -305,14 +305,7 @@ end
local function builtin_receive_pack_run(config, repo, cmdline, env)
local cmdcopy = {"receive-pack", env=env}
for i = 2, #cmdline do cmdcopy[i] = cmdline[i] end
- local how, why = repo:git_command(cmdcopy)
- -- Check that HEAD is now resolvable in the repo
- if how == "exit" and why == 0 and not repo.git:get("HEAD") then
- log.warn("")
- log.warn("HEAD remains dangling")
- log.warn("")
- end
- return how, why
+ return repo:git_command(cmdcopy)
end
assert(register_cmd("git-receive-pack", nil, nil,