diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2014-04-16 16:43:15 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2014-04-16 16:43:15 +0000 |
commit | d5a76a5caf51d12c811317ac6e376942b7633770 (patch) | |
tree | 052087c2f293c0a7fc94a7b8c5f0f6ac066f44df | |
parent | 77266b3ec2efec51f0a3246cbad70a4f15835958 (diff) | |
parent | 93f36f49ff6a92f307e1eacbdd91673734ca7dc5 (diff) | |
download | gitano-d5a76a5caf51d12c811317ac6e376942b7633770.tar.gz |
Merge branch 'master' into baserock/morph
This merges in a gitano-command.cgi command parsing fix that we'll
need for the new Lorry Controller.
I've tested this in my system branch.
-rw-r--r-- | Makefile | 10 | ||||
-rwxr-xr-x | bin/gitano-command.cgi.in | 7 | ||||
-rw-r--r-- | bin/gitano-update-hook.in | 9 | ||||
-rw-r--r-- | lib/gitano/auth.lua | 2 | ||||
-rw-r--r-- | lib/gitano/util.lua | 8 | ||||
-rw-r--r-- | plugins/rsync.lua | 5 |
6 files changed, 33 insertions, 8 deletions
@@ -155,9 +155,17 @@ install-plugins: install -m 644 plugins/$$PLUGIN $(DESTDIR)$(INST_ROOT)/lib/gitano/plugins; \ done +YARN_ARGS := +ifneq ($(LUA_PATH),) +YARN_ARGS += --env LUA_PATH="$(LUA_PATH)" +endif +ifneq ($(LUA_CPATH),) +YARN_ARGS += --env LUA_CPATH="$(LUA_CPATH)" +endif + test: local $(TEST_BINS) @$(YARN) --env GTT="$$(pwd)/testing/gitano-test-tool" \ - --env LUA_PATH="$(LUA_PATH)" --env LUA_CPATH="$(LUA_CPATH)" \ + $(YARN_ARGS) \ testing/library.yarn $(TESTS) testing/%: testing/%.in $(GEN_BIN) diff --git a/bin/gitano-command.cgi.in b/bin/gitano-command.cgi.in index ba16538..1954635 100755 --- a/bin/gitano-command.cgi.in +++ b/bin/gitano-command.cgi.in @@ -29,7 +29,7 @@ function url_decode(str) return str end -function run_command(cmd, cmdline, parsed_cmdline, user, config, env) +function run_command(cmd, cmdline, parsed_cmdline, user, config, env, repo) gitano.log.debug("Welcome to " .. config.global.site_name) gitano.log.debug("Running:") for i = 1, #parsed_cmdline do @@ -73,11 +73,12 @@ if os.getenv("QUERY_STRING") then gitano.log.buffer_output() - local authorized, cmd, parsed_cmdline, config, env = + local authorized, cmd, parsed_cmdline, config, env, repo = gitano.auth.is_authorized(user, "http", cmdline) if authorized then - local exit = run_command(cmd, cmdline, parsed_cmdline, user, config, env) + local exit = run_command(cmd, cmdline, parsed_cmdline, + user, config, env, repo) stdout:write("Status: " .. (exit == 0 and "200 OK" or "400 Bad request") .. "\r\n\r\n") diff --git a/bin/gitano-update-hook.in b/bin/gitano-update-hook.in index 34acbf9..bb7d8fe 100644 --- a/bin/gitano-update-hook.in +++ b/bin/gitano-update-hook.in @@ -93,18 +93,24 @@ local context = { -- Attempt to work out what's going on regarding the update. +local action = "**UNKNOWN**" + if oldsha == nullsha and newsha ~= nullsha then context["operation"] = "createref" + action = "creation" elseif oldsha ~= nullsha and newsha == nullsha then context["operation"] = "deleteref" + action = "deletion" else local base, msg = repo.git:merge_base(oldsha, newsha) if not base then gitano.log.fatal(msg) elseif (base == true) or ((base) and (base == newsha)) then context["operation"] = "updaterefnonff" + action = "non-ff update" else context["operation"] = "updaterefff" + action = "update" end end @@ -283,7 +289,8 @@ end gitano.log.info("Allowing ref update of", refname, "from", oldsha, "to", newsha) -gitano.log.syslog.info("Allowing ref update of", refname) +gitano.log.syslog.info("Allowing ref", action, "of", refname, + "( was", oldsha, "is now", newsha, ")") gitano.log.syslog.close() diff --git a/lib/gitano/auth.lua b/lib/gitano/auth.lua index 8f288e6..8c3a4e6 100644 --- a/lib/gitano/auth.lua +++ b/lib/gitano/auth.lua @@ -127,7 +127,7 @@ local function is_authorized(user, source, cmdline) log.critical("Ruleset denied action. Sorry.") end - return authorized, cmd, parsed_cmdline, admin_conf, env + return authorized, cmd, parsed_cmdline, admin_conf, env, repo end return { diff --git a/lib/gitano/util.lua b/lib/gitano/util.lua index c2a53a7..291c68d 100644 --- a/lib/gitano/util.lua +++ b/lib/gitano/util.lua @@ -337,12 +337,18 @@ end local tagname_pattern = "^[a-z0-9_%-/]*[a-z0-9_%-]*$" +local cached_expansions = {} + local function prep_expansion(str) -- Parse 'str' and return a table representing a sequence of -- operations required to evaluate the expansion of the string. -- in the simple case, it's merely the string in a table -- if the entry in ret is a string, it's copied. If it's a table -- then that table's [1] is a string which is a tag name to expand. + if cached_expansions[str] then + return cached_expansions[str] + end + local ret = {} local acc = "" local c @@ -386,6 +392,8 @@ local function prep_expansion(str) ret[#ret+1] = acc end + cached_expansions[str] = ret + return ret end diff --git a/plugins/rsync.lua b/plugins/rsync.lua index 310fe59..8f8c8da 100644 --- a/plugins/rsync.lua +++ b/plugins/rsync.lua @@ -39,9 +39,10 @@ local function rsync_detect_repo(config, cmdline) -- Basically, while there's still something to the repopath -- and we've not yet found a repo, strip an element and try again... - while not repo and repopath ~= ""do + while (not repo or repo.is_nascent) and repopath ~= ""do + gitano.log.error("Trying " .. repopath) repo, msg = gitano.repository.find(config, repopath) - if not repo then + if not repo or repo.is_nascent then repopath = repopath:match("^(.*)/[^/]*$") or "" end end |