From dadc1a40cf197bfa4e18129522eebdda311fe734 Mon Sep 17 00:00:00 2001 From: Konctantin Date: Tue, 12 Nov 2019 13:52:28 +0300 Subject: [PATCH 1/5] Add code highlighter to GitHook edit Signed-off-by: Konctantin --- public/js/index.js | 12 ++++++++++++ routers/repo/setting.go | 1 + 2 files changed, 13 insertions(+) diff --git a/public/js/index.js b/public/js/index.js index af31418371424..2a94e92a3c42d 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1637,6 +1637,17 @@ function initUserSettings() { } } +function initGithook() { + if ($('.edit.githook').length == 0) { + return; + } + + CodeMirror.autoLoadMode(CodeMirror.fromTextArea($('#content')[0], { + lineNumbers: true, + mode: 'shell' + }), 'shell'); +} + function initWebhook() { if ($('.new.webhook').length == 0) { return; @@ -2409,6 +2420,7 @@ $(document).ready(function () { initEditForm(); initEditor(); initOrganization(); + initGithook(); initWebhook(); initAdmin(); initCodeView(); diff --git a/routers/repo/setting.go b/routers/repo/setting.go index f699c1d685641..3ba5f4a66fc38 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -697,6 +697,7 @@ func GitHooks(ctx *context.Context) { func GitHooksEdit(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.settings.githooks") ctx.Data["PageIsSettingsGitHooks"] = true + ctx.Data["RequireSimpleMDE"] = true name := ctx.Params(":name") hook, err := ctx.Repo.GitRepo.GetHook(name) From 12f0ea6cfaed833872c30fe1a0d41cab7a2a4c73 Mon Sep 17 00:00:00 2001 From: Konctantin Date: Tue, 12 Nov 2019 13:57:11 +0300 Subject: [PATCH 2/5] Fix indentation Signed-off-by: Konctantin --- public/js/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/js/index.js b/public/js/index.js index 2a94e92a3c42d..363c32a569242 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1642,10 +1642,10 @@ function initGithook() { return; } - CodeMirror.autoLoadMode(CodeMirror.fromTextArea($('#content')[0], { - lineNumbers: true, - mode: 'shell' - }), 'shell'); + CodeMirror.autoLoadMode(CodeMirror.fromTextArea($('#content')[0], { + lineNumbers: true, + mode: 'shell' + }), 'shell'); } function initWebhook() { From 292a6fdedaefe3a904c25b4e8f49e008726e3acf Mon Sep 17 00:00:00 2001 From: "gawrilyako@gmail.com" Date: Thu, 14 Nov 2019 23:22:03 +0300 Subject: [PATCH 3/5] Resolve merge conflict Signed-off-by: gawrilyako@gmail.com --- web_src/js/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/web_src/js/index.js b/web_src/js/index.js index 2edd70c87d5bc..26ab1c75ab771 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -1637,6 +1637,17 @@ function initUserSettings() { } } +function initGithook() { + if ($('.edit.githook').length == 0) { + return; + } + + CodeMirror.autoLoadMode(CodeMirror.fromTextArea($('#content')[0], { + lineNumbers: true, + mode: 'shell' + }), 'shell'); +} + function initWebhook() { if ($('.new.webhook').length == 0) { return; @@ -2409,6 +2420,7 @@ $(document).ready(function () { initEditForm(); initEditor(); initOrganization(); + initGithook(); initWebhook(); initAdmin(); initCodeView(); From 06d3dcc876961686fa1787ceba9cff25b638402a Mon Sep 17 00:00:00 2001 From: "gawrilyako@gmail.com" Date: Fri, 15 Nov 2019 08:10:16 +0300 Subject: [PATCH 4/5] Resolve merge conflict Signed-off-by: gawrilyako@gmail.com --- web_src/js/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/web_src/js/index.js b/web_src/js/index.js index 69d2aafcc9526..6d2812d8f84e8 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -1499,6 +1499,17 @@ function initUserSettings() { } } +function initGithook() { + if ($('.edit.githook').length == 0) { + return; + } + + CodeMirror.autoLoadMode(CodeMirror.fromTextArea($('#content')[0], { + lineNumbers: true, + mode: 'shell' + }), 'shell'); +} + function initWebhook() { if ($('.new.webhook').length === 0) { return; @@ -2296,6 +2307,7 @@ $(document).ready(() => { initEditForm(); initEditor(); initOrganization(); + initGithook(); initWebhook(); initAdmin(); initCodeView(); From 092bf9139a7cdc0f2396dacbce4fb4712b6bcecf Mon Sep 17 00:00:00 2001 From: Konctantin Date: Fri, 15 Nov 2019 09:28:56 +0300 Subject: [PATCH 5/5] Fix pre-build drone event Signed-off-by: Konctantin --- web_src/js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/index.js b/web_src/js/index.js index 6d2812d8f84e8..e25568d9b8ba0 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -1500,7 +1500,7 @@ function initUserSettings() { } function initGithook() { - if ($('.edit.githook').length == 0) { + if ($('.edit.githook').length === 0) { return; }