diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2016-08-20 15:14:20 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2016-08-20 15:14:20 +0100 |
commit | 57064c80f28daf490e5c3349a00696aba585b840 (patch) | |
tree | 1fbd736a8e86db87c247db800b57a53a9550d3e7 /lib | |
parent | efb95e0f4d4e026b63209c48f59e9c9ca59cb29c (diff) | |
download | gitano-57064c80f28daf490e5c3349a00696aba585b840.tar.gz |
Remove set-owner and ensure setting project.owner gets validated
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitano/command.lua | 59 |
1 files changed, 7 insertions, 52 deletions
diff --git a/lib/gitano/command.lua b/lib/gitano/command.lua index 7d6c8d0..717c872 100644 --- a/lib/gitano/command.lua +++ b/lib/gitano/command.lua @@ -300,58 +300,6 @@ assert(register_cmd("create", builtin_create_short, builtin_create_helptext, builtin_create_validate, builtin_create_prep, builtin_create_run, true, false)) -local builtin_set_owner_short = "Sets the owner of a repository" -local builtin_set_owner_helptext = [[ -usage: set-owner <reponame> <owner> - -Set the owner of a repository. Who is allowed to do this is configured -by the site administrators. Typically site admins and repository owners -are the only people allowed to change the ownership of a repository. -]] - -local function builtin_set_owner_validate(config, repo, cmdline) - -- set-owner reponame ownername - if #cmdline ~= 3 then - log.error("usage: set-owner <reponame> <owner>") - return false - end - if not repo then - log.error("No repository?") - return false - end - if repo.is_nascent then - log.error("Repository", repo.name, "does not exist, use create") - return false - end - if not config.users[cmdline[3]] then - log.error("Unknown user:", cmdline[3]) - return false - end - return true -end - -local function builtin_set_owner_prep(config, repo, cmdline, context) - context.operation = "setowner" - return repo:run_lace(context) -end - -local function builtin_set_owner_run(config, repo, cmdline, env) - local owner = cmdline[3] - log.chat("Setting repository owner to", owner) - ok, msg = repo:set_owner(owner, env.GITANO_USER, env.GITANO_ORIG_USER) - if not ok then - log.error(msg) - return "exit", 1 - end - log.state("Ownership of repository", repo.name, "transferred ok.") - return "exit", 0 -end - -assert(register_cmd("set-owner", builtin_set_owner_short, - builtin_set_owner_helptext, builtin_set_owner_validate, - builtin_set_owner_prep, builtin_set_owner_run, - true, false)) - local builtin_set_head_short = "Set the repo's HEAD symbolic reference" local builtin_set_head_helptext = [[ usage: set-head <repo> <ref> @@ -491,6 +439,13 @@ local function builtin_config_validate(conf, repo, cmdline) end cmdline[5] = table.concat(cpy, " ") end + if cmdline[4] == "project.owner" then + -- Verify that the new owner is a valid user + if not conf.users[cmdline[5]] then + log.error("Unknown user: " .. cmdline[5]) + return false + end + end elseif cmdline[3] == "del" or cmdline[3] == "delete" or cmdline[3] == "rm" then cmdline[3] = "del" |