diff --git a/plugins/gogs/index.py b/plugins/gogs/index.py
index 7eec258c5..550bd3a67 100755
--- a/plugins/gogs/index.py
+++ b/plugins/gogs/index.py
@@ -821,7 +821,7 @@ def projectScriptSelf_Create():
if os.path.exists(abs_file):
return mw.returnJson(False, '脚本已经存在!')
- mw.writeFile(abs_file, "#!/bin/bash\n")
+ mw.writeFile(abs_file, "#!/bin/bash\necho `date +'%Y-%m-%d %H:%M:%S'`\n")
rdata = {}
rdata['abs_file'] = abs_file
@@ -885,6 +885,26 @@ def projectScriptSelf_Logs():
return mw.returnJson(False, '日志不存在!')
+def projectScriptSelf_Run():
+ args = getArgs()
+ data = checkArgs(args, ['user', 'name', 'file'])
+ if not data[0]:
+ return data[1]
+
+ user = args['user']
+ name = args['name'] + '.git'
+ file = args['file']
+
+ custom_hooks = getRootPath() + '/' + user + '/' + \
+ name + '/custom_hooks'
+ self_path = custom_hooks + '/self/' + file
+ self_logs_path = custom_hooks + '/self_logs/' + file + '.log'
+
+ shell = "sh -x " + self_path + " 2>" + self_logs_path
+ mw.execShell(shell)
+ return mw.returnJson(True, '执行成功!')
+
+
def projectScriptSelf_Rename():
args = getArgs()
data = checkArgs(args, ['user', 'name', 'o_file', 'n_file'])
@@ -1031,6 +1051,8 @@ if __name__ == "__main__":
print(projectScriptSelf_Del())
elif func == 'project_script_self_logs':
print(projectScriptSelf_Logs())
+ elif func == 'project_script_self_run':
+ print(projectScriptSelf_Run())
elif func == 'project_script_self_rename':
print(projectScriptSelf_Rename())
elif func == 'project_script_self_enable':
diff --git a/plugins/gogs/js/gogs.js b/plugins/gogs/js/gogs.js
index edd087b7a..ef6a0cb6c 100755
--- a/plugins/gogs/js/gogs.js
+++ b/plugins/gogs/js/gogs.js
@@ -534,6 +534,7 @@ function projectScriptSelfRender(user, name){
'删除' + ' | ' +
'编辑' + ' | ' +
'日志' + ' | ' +
+ '手动' + ' | ' +
'重命名' +
'';
}
@@ -574,6 +575,15 @@ function projectScriptSelfRender(user, name){
});
});
+ $('#gogs_self_table .run').click(function(){
+ var i = $(this).data('index');
+ var file = data[i]["name"];
+ gogsPost('project_script_self_run', {'user':user,'name':name,'file':file}, function(data){
+ var rdata = $.parseJSON(data.data);
+ layer.msg(rdata.msg,{icon:data.status?1:2,time:2000,shade: [0.3, '#000']});
+ });
+ });
+
$('#gogs_self_table .rename').click(function(){
var i = $(this).data('index');