mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
improve mercurial hook error handling
This commit is contained in:
@@ -42,21 +42,32 @@ baseUrl = os.environ['SCM_URL']
|
|||||||
challenge = os.environ['SCM_CHALLENGE']
|
challenge = os.environ['SCM_CHALLENGE']
|
||||||
credentials = os.environ['SCM_CREDENTIALS']
|
credentials = os.environ['SCM_CREDENTIALS']
|
||||||
|
|
||||||
|
def callHookUrl(ui, repo, hooktype, node):
|
||||||
|
abort = True
|
||||||
|
try:
|
||||||
|
url = baseUrl + hooktype
|
||||||
|
ui.debug( "send scm-hook to " + url + " and " + node + "\n" )
|
||||||
|
data = urllib.urlencode({'node': node, 'challenge': challenge, 'credentials': credentials, 'repositoryPath': repo.root})
|
||||||
|
conn = urllib2.urlopen(url, data);
|
||||||
|
if conn.code >= 200 and conn.code < 300:
|
||||||
|
ui.debug( "scm-hook " + hooktype + " success with status code " + str(conn.code) + "\n" )
|
||||||
|
abort = False
|
||||||
|
else:
|
||||||
|
ui.warn( "ERROR: scm-hook failed with error code " + str(conn.code) + "\n" )
|
||||||
|
except ValueError:
|
||||||
|
ui.warn( "scm-hook failed with an exception\n" )
|
||||||
|
return abort
|
||||||
|
|
||||||
def callback(ui, repo, hooktype, node=None, source=None, pending=None, **kwargs):
|
def callback(ui, repo, hooktype, node=None, source=None, pending=None, **kwargs):
|
||||||
if pending != None:
|
if pending != None:
|
||||||
pending()
|
pending()
|
||||||
failure = True
|
abort = True
|
||||||
if node != None:
|
if node != None:
|
||||||
try:
|
if len(baseUrl) > 0:
|
||||||
url = baseUrl + hooktype
|
abort = callHookUrl(ui, repo, hooktype, node)
|
||||||
ui.debug( "send scm-hook to " + url + " and " + node + "\n" )
|
else:
|
||||||
data = urllib.urlencode({'node': node, 'challenge': challenge, 'credentials': credentials, 'repositoryPath': repo.root})
|
ui.warn("ERROR: scm-manager hooks are disabled, please check your configuration and the scm-manager log for details\n")
|
||||||
conn = urllib2.urlopen(url, data);
|
abort = False
|
||||||
if conn.code >= 200 and conn.code < 300:
|
else:
|
||||||
ui.debug( "scm-hook " + hooktype + " success with status code " + str(conn.code) + "\n" )
|
ui.warn("changeset node is not available")
|
||||||
failure = False
|
return abort
|
||||||
else:
|
|
||||||
ui.warn( "scm-hook failed with error code " + str(conn.code) + "\n" )
|
|
||||||
except ValueError:
|
|
||||||
ui.warn( "scm-hook failed with an exception\n" )
|
|
||||||
return failure
|
|
||||||
|
|||||||
Reference in New Issue
Block a user