From b5503750fcf752ba612d388e6cf3c39d86e38c73 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 14 Mar 2014 17:28:22 +0000 Subject: Allow tests to run even when not inside gitano-all --- Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cab0162..9651c0e 100644 --- a/Makefile +++ b/Makefile @@ -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) -- cgit v1.2.1 From 69085b691188bdb6d1345eeaeb94f0f3f1506f70 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 22 Mar 2014 18:33:33 +0000 Subject: Cache expansions --- lib/gitano/util.lua | 8 ++++++++ 1 file changed, 8 insertions(+) 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 -- cgit v1.2.1 From fd908026c2d12ac83c51fe9ed57c3316230ea105 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 4 Apr 2014 09:32:00 +0100 Subject: Support rsync directly to subdirectories --- plugins/rsync.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 -- cgit v1.2.1 From a880701ddeadf5a2280a9d5ab710e29c86db09bc Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Fri, 4 Apr 2014 15:43:57 +0100 Subject: UPDATE-HOOK: Extra audit message information Increase the audit log message data to include the update action type, and the old and new SHA. Signed-off-by: Daniel Silverstone --- bin/gitano-update-hook.in | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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() -- cgit v1.2.1 From 93f36f49ff6a92f307e1eacbdd91673734ca7dc5 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Wed, 9 Apr 2014 11:55:19 +0100 Subject: Ensure we pass the repo through otherwise HTTP commands might not work --- bin/gitano-command.cgi.in | 7 ++++--- lib/gitano/auth.lua | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) 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/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 { -- cgit v1.2.1