From ef755a82d9d34c9892c348aa4b0385016be2f13b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauris=20Buk=C5=A1is-Haberkorns?= Date: Sun, 10 Sep 2017 19:26:39 +0300 Subject: [PATCH 1/3] Basic VSCode configuration for building and debugging --- .gitignore | 1 + .vscode/launch.json | 31 +++++++++++++++++++++++++++++++ .vscode/tasks.json | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json diff --git a/.gitignore b/.gitignore index e3274c5057b70..d91986d844805 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ _testmain.go *.log /gitea +/debug /integrations.test /bin diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000000..af1594cd5d8a4 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,31 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Launch", + "type": "go", + "request": "launch", + "mode": "debug", + "buildFlags": "", + "port": 2345, + "host": "127.0.0.1", + "program": "${workspaceRoot}/main.go", + "env": {}, + "args": ["web"], + "showLog": true + }, + { + "name": "Launch (with SQLite3)", + "type": "go", + "request": "launch", + "mode": "debug", + "buildFlags": "-tags=\"sqlite\"", + "port": 2345, + "host": "127.0.0.1", + "program": "${workspaceRoot}/main.go", + "env": {}, + "args": ["web"], + "showLog": true + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000000000..e3d0f5a189b11 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,39 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "taskName": "Build", + "type": "shell", + "command": "go", + "group": "build", + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared" + }, + "args": ["build", "-o", "gitea", "${workspaceRoot}/main.go"], + "windows": { + "args": ["build", "-o", "gitea.exe", "${workspaceRoot}/main.go"] + }, + "problemMatcher": ["$go"] + }, + { + "taskName": "Build (with SQLite3)", + "type": "shell", + "command": "go", + "group": "build", + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared" + }, + "args": ["build", "-tags=\"sqlite\"", "-o", "gitea", "${workspaceRoot}/main.go"], + "windows": { + "args": ["build", "-tags=\"sqlite\"", "-o", "gitea.exe", "${workspaceRoot}/main.go"] + }, + "problemMatcher": ["$go"] + } + ] +} From abf307d7f1b65cb35877e9c93ff3d443e1893a86 Mon Sep 17 00:00:00 2001 From: Lauris BH Date: Mon, 11 Sep 2017 17:17:34 +0300 Subject: [PATCH 2/3] Fix building and debugging in Windows --- .vscode/tasks.json | 20 ++++++++++++++++---- modules/setting/setting.go | 6 +++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index e3d0f5a189b11..8527d91c8f549 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -12,9 +12,15 @@ "focus": false, "panel": "shared" }, - "args": ["build", "-o", "gitea", "${workspaceRoot}/main.go"], + "args": ["build"], + "linux": { + "args": [ "-o", "gitea", "${workspaceRoot}/main.go" ] + }, + "osx": { + "args": [ "-o", "gitea", "${workspaceRoot}/main.go" ] + }, "windows": { - "args": ["build", "-o", "gitea.exe", "${workspaceRoot}/main.go"] + "args": [ "-o", "gitea.exe", "\"${workspaceRoot}\\main.go\""] }, "problemMatcher": ["$go"] }, @@ -29,9 +35,15 @@ "focus": false, "panel": "shared" }, - "args": ["build", "-tags=\"sqlite\"", "-o", "gitea", "${workspaceRoot}/main.go"], + "args": ["build", "-tags=\"sqlite\""], + "linux": { + "args": ["-o", "gitea", "${workspaceRoot}/main.go"] + }, + "osx": { + "args": ["-o", "gitea", "${workspaceRoot}/main.go"] + }, "windows": { - "args": ["build", "-tags=\"sqlite\"", "-o", "gitea.exe", "${workspaceRoot}/main.go"] + "args": ["-o", "gitea.exe", "\"${workspaceRoot}\\main.go\""] }, "problemMatcher": ["$go"] } diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 721dd0f0f75c0..4932f51a68d2f 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -500,7 +500,11 @@ func DateLang(lang string) string { // execPath returns the executable path. func execPath() (string, error) { - file, err := exec.LookPath(os.Args[0]) + execFile := os.Args[0] + if IsWindows && filepath.IsAbs(execFile) { + return filepath.Clean(execFile), nil + } + file, err := exec.LookPath(execFile) if err != nil { return "", err } From ae6442c20d4aac16cde62e3cd1090ba29c2f110e Mon Sep 17 00:00:00 2001 From: Lauris BH Date: Mon, 11 Sep 2017 19:01:24 +0300 Subject: [PATCH 3/3] Move to contrib folder and add instructions --- .gitignore | 3 +++ CONTRIBUTING.md | 2 ++ contrib/ide/README.md | 12 ++++++++++++ {.vscode => contrib/ide/vscode}/launch.json | 0 {.vscode => contrib/ide/vscode}/tasks.json | 0 5 files changed, 17 insertions(+) create mode 100644 contrib/ide/README.md rename {.vscode => contrib/ide/vscode}/launch.json (100%) rename {.vscode => contrib/ide/vscode}/tasks.json (100%) diff --git a/.gitignore b/.gitignore index d91986d844805..1a1aa568bca33 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,9 @@ _test # IntelliJ .idea +# MS VSCode +.vscode + # Architecture specific extensions/prefixes *.[568vq] [568vq].out diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e58d8e30702d5..7422f43f1d9d8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,6 +26,8 @@ It assumes you have followed the Sensitive security-related issues should be reported to [security@gitea.io](mailto:security@gitea.io). +For configuring IDE or code editor to develop Gitea see [IDE and code editor configuration](contrib/ide/) + ## Bug reports Please search the issues on the issue tracker with a variety of keywords diff --git a/contrib/ide/README.md b/contrib/ide/README.md new file mode 100644 index 0000000000000..80b6a8aad97e8 --- /dev/null +++ b/contrib/ide/README.md @@ -0,0 +1,12 @@ +# IDE and code editor configuration + +## Table of Contents +- [IDE and code editor configuration](#ide-and-code-editor-configuration) + - [Microsoft Visual Studio Code](#microsoft-visual-studio-code) + +## Microsoft Visual Studio Code +Download Microsoft Visual Studio Code at https://code.visualstudio.com/ and follow instructions at https://code.visualstudio.com/docs/languages/go to setup Go extension for it. + +Create new direcotry `.vscode` in Gitea root folder and copy contents of folder [contrib/ide/vscode](vscode/) to it. You can now use `Ctrl`+`Shift`+`B` to build gitea executable and `F5` to run it in debug mode. + +Supported on Debian, Ubuntu, Red Hat, Fedora, SUSE Linux, MacOS and Microsoft Windows. diff --git a/.vscode/launch.json b/contrib/ide/vscode/launch.json similarity index 100% rename from .vscode/launch.json rename to contrib/ide/vscode/launch.json diff --git a/.vscode/tasks.json b/contrib/ide/vscode/tasks.json similarity index 100% rename from .vscode/tasks.json rename to contrib/ide/vscode/tasks.json