更改gogs- hook脚本

pull/109/head
Mr Chen 6 years ago
parent 356f968fed
commit 2c640f4439
  1. 2
      plugins/gogs/hook/commit.tpl
  2. 13
      plugins/gogs/index.py

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
GITADDR="{$GITROOTURL}{$USERNAME}/{$PROJECT}" GITADDR="{$GITROOTURL}/{$USERNAME}/{$PROJECT}"
GIT_SDIR="{$CODE_DIR}" GIT_SDIR="{$CODE_DIR}"
GIT_USER_DIR="${GIT_SDIR}/{$USERNAME}" GIT_USER_DIR="${GIT_SDIR}/{$USERNAME}"

@ -159,6 +159,15 @@ def getRootUrl():
return tmp.groups()[0] return tmp.groups()[0]
def getSshPort():
content = public.readFile(getConf())
rep = 'SSH_PORT\s*=\s*(.*)'
tmp = re.search(rep, content)
if not tmp:
return ''
return tmp.groups()[0]
def getRootPath(): def getRootPath():
content = public.readFile(getConf()) content = public.readFile(getConf())
rep = 'ROOT\s*=\s*(.*)' rep = 'ROOT\s*=\s*(.*)'
@ -530,7 +539,9 @@ def projectScriptLoad():
codeDir = public.getRootDir() + '/git' codeDir = public.getRootDir() + '/git'
cc_content = public.readFile(commit_tpl) cc_content = public.readFile(commit_tpl)
cc_content = cc_content.replace('{$GITROOTURL}', getRootUrl())
sshUrl = 'ssh://127.0.0.1:' + getSshPort()
cc_content = cc_content.replace('{$GITROOTURL}', sshUrl)
cc_content = cc_content.replace('{$CODE_DIR}', codeDir) cc_content = cc_content.replace('{$CODE_DIR}', codeDir)
cc_content = cc_content.replace('{$USERNAME}', user) cc_content = cc_content.replace('{$USERNAME}', user)
cc_content = cc_content.replace('{$PROJECT}', args['name']) cc_content = cc_content.replace('{$PROJECT}', args['name'])

Loading…
Cancel
Save