From bae1d655640d901345c18ec9689fd33eaf0a9760 Mon Sep 17 00:00:00 2001 From: estetsenko Date: Wed, 24 Dec 2014 20:47:45 +0300 Subject: [PATCH 1/5] bugfix: Unable to assign any issue myself --- models/issue.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/issue.go b/models/issue.go index 8004647c72..c756e49759 100644 --- a/models/issue.go +++ b/models/issue.go @@ -472,8 +472,8 @@ func UpdateIssueUserPairByAssignee(aid, iid int64) error { if aid == 0 { return nil } - rawSql = "UPDATE `issue_user` SET is_assigned = true WHERE uid = ? AND issue_id = ?" - _, err := x.Exec(rawSql, aid, iid) + rawSql = "UPDATE `issue_user` SET is_assigned = ? WHERE uid = ? AND issue_id = ?" + _, err := x.Exec(rawSql, true, aid, iid) return err } From afc659442d4c24b92e53f02dd331a9e05e10773e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gr=C3=B6tschel?= Date: Sat, 27 Dec 2014 15:16:05 +0100 Subject: [PATCH 2/5] flexiable the build scripts and add a freebsd build script --- scripts/build.sh | 42 +++++++++++++++++++----------------- scripts/build_freebsd.sh | 27 +++++++++++++++++++++++ scripts/build_linux64.sh | 46 +++++++++++++++++++++++----------------- 3 files changed, 76 insertions(+), 39 deletions(-) create mode 100755 scripts/build_freebsd.sh diff --git a/scripts/build.sh b/scripts/build.sh index 03b8077bf7..ea43bdafcb 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,21 +1,25 @@ -rm -rf output -mkdir output +outPath=./output + +rm -rf $outPath +mkdir $outPath + go build ../gogs.go chmod +x gogs -mv gogs ./output/ -cp -r ../conf/ ./output/conf/ -cp -r ../custom/ ./output/custom/ -cp -r ./dockerfiles/ ./output/dockerfiles/ -cp -r ../public/ ./output/public/ -cp -r ../templates/ ./output/templates/ -cp ../cert.pem ./output/ -cp ../CONTRIBUTING.md ./output/ -cp gogs_supervisord.sh ./output/ -cp ../key.pem ./output/ -cp ../LICENSE ./output/ -cp ../README.md ./output/ -cp ../README_ZH.md ./output/ -cp start.bat ./output/ -cp start.sh ./output/ -cp ../wercker.yml ./output/ -cp mysql.sql ./output/ +mv gogs $outPath/ + +cp -r ../conf/ $outPath/conf/ +cp -r ../custom/ $outPath/custom/ +cp -r dockerfiles/ $outPath/dockerfiles/ +cp -r ../public/ $outPath/public/ +cp -r ../templates/ $outPath/templates/ +cp ../cert.pem $outPath/ +cp ../CONTRIBUTING.md $outPath/ +cp gogs_supervisord.sh $outPath/ +cp ../key.pem $outPath/ +cp ../LICENSE $outPath/ +cp ../README.md $outPath/ +cp ../README_ZH.md $outPath/ +cp start.bat $outPath/ +cp start.sh $outPath/ +cp ../wercker.yml $outPath/ +cp mysql.sql $outPath/ \ No newline at end of file diff --git a/scripts/build_freebsd.sh b/scripts/build_freebsd.sh new file mode 100755 index 0000000000..b53c6ac0d5 --- /dev/null +++ b/scripts/build_freebsd.sh @@ -0,0 +1,27 @@ +outPlattform=freebsd +outArch=amd64 +outPath=./output_$outPlattform_$outArch + +rm -rf $outPath +mkdir $outPath + +CGO_ENABLED=0 GOOS=$outPlattform GOARCH=$outArch go build ../gogs.go +chmod +x gogs +mv gogs $outPath/ + +cp -r ../conf/ $outPath/conf/ +cp -r ../custom/ $outPath/custom/ +cp -r dockerfiles/ $outPath/dockerfiles/ +cp -r ../public/ $outPath/public/ +cp -r ../templates/ $outPath/templates/ +cp ../cert.pem $outPath/ +cp ../CONTRIBUTING.md $outPath/ +cp gogs_supervisord.sh $outPath/ +cp ../key.pem $outPath/ +cp ../LICENSE $outPath/ +cp ../README.md $outPath/ +cp ../README_ZH.md $outPath/ +cp start.bat $outPath/ +cp start.sh $outPath/ +cp ../wercker.yml $outPath/ +cp mysql.sql $outPath/ \ No newline at end of file diff --git a/scripts/build_linux64.sh b/scripts/build_linux64.sh index eb6c04e579..528fc54cf0 100755 --- a/scripts/build_linux64.sh +++ b/scripts/build_linux64.sh @@ -1,21 +1,27 @@ -rm -rf output_linux_64 -mkdir output_linux_64 -CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ../gogs.go +outPlattform=linux +outArch=amd64 +outPath=./output_$outPlattform_$outArch + +rm -rf $outPath +mkdir $outPath + +CGO_ENABLED=0 GOOS=$outPlattform GOARCH=$outArch go build ../gogs.go chmod +x gogs -mv gogs ./output_linux_64/ -cp -r ../conf/ ./output_linux_64/conf/ -cp -r ../custom/ ./output_linux_64/custom/ -cp -r dockerfiles/ ./output_linux_64/dockerfiles/ -cp -r ../public/ ./output_linux_64/public/ -cp -r ../templates/ ./output_linux_64/templates/ -cp ../cert.pem ./output_linux_64/ -cp ../CONTRIBUTING.md ./output_linux_64/ -cp gogs_supervisord.sh ./output_linux_64/ -cp ../key.pem ./output_linux_64/ -cp ../LICENSE ./output_linux_64/ -cp ../README.md ./output_linux_64/ -cp ../README_ZH.md ./output_linux_64/ -cp start.bat ./output_linux_64/ -cp start.sh ./output_linux_64/ -cp ../wercker.yml ./output_linux_64/ -cp mysql.sql ./output_linux_64/ \ No newline at end of file +mv gogs $outPath/ + +cp -r ../conf/ $outPath/conf/ +cp -r ../custom/ $outPath/custom/ +cp -r dockerfiles/ $outPath/dockerfiles/ +cp -r ../public/ $outPath/public/ +cp -r ../templates/ $outPath/templates/ +cp ../cert.pem $outPath/ +cp ../CONTRIBUTING.md $outPath/ +cp gogs_supervisord.sh $outPath/ +cp ../key.pem $outPath/ +cp ../LICENSE $outPath/ +cp ../README.md $outPath/ +cp ../README_ZH.md $outPath/ +cp start.bat $outPath/ +cp start.sh $outPath/ +cp ../wercker.yml $outPath/ +cp mysql.sql $outPath/ \ No newline at end of file From 234a7c19a4a59632dadaf430ab2431dccc0d74a9 Mon Sep 17 00:00:00 2001 From: euank Date: Sat, 27 Dec 2014 19:07:54 -0800 Subject: [PATCH 3/5] Default values for both user.name and user.email The previous behavior was to set default values only if user.name was not set, but to always set it for both. This only sets a value if there wasn't one; this fixes cases where someone has a user.name but no user.email (see included Dockerfile) or someone has a user.email but no user.name (before the email would have been over-written). --- models/repo.go | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/models/repo.go b/models/repo.go index 3ea4efc7f0..50b2b3fc25 100644 --- a/models/repo.go +++ b/models/repo.go @@ -105,21 +105,18 @@ func NewRepoContext() { log.Fatal(4, "Gogs requires Git version greater or equal to 1.7.1") } - // Check if server has basic git setting and set if not. - if stdout, stderr, err := process.Exec("NewRepoContext(get setting)", "git", "config", "--get", "user.name"); err != nil || strings.TrimSpace(stdout) == "" { - // ExitError indicates user.name is not set - if _, ok := err.(*exec.ExitError); ok || strings.TrimSpace(stdout) == "" { - stndrdUserName := "Gogs" - stndrdUserEmail := "gogitservice@gmail.com" - if _, stderr, gerr := process.Exec("NewRepoContext(set name)", "git", "config", "--global", "user.name", stndrdUserName); gerr != nil { - log.Fatal(4, "Fail to set git user.name(%s): %s", gerr, stderr) + // Check if server has user.email and user.name set correctly and set if they're not. + for configKey, defaultValue := range map[string]string{"user.name": "Gogs", "user.email": "gogitservice@gmail.com"} { + if stdout, stderr, err := process.Exec("NewRepoContext(get setting)", "git", "config", "--get", configKey); err != nil || strings.TrimSpace(stdout) == "" { + // ExitError indicates this config is not set + if _, ok := err.(*exec.ExitError); ok || strings.TrimSpace(stdout) == "" { + if _, stderr, gerr := process.Exec("NewRepoContext(set "+configKey+")", "git", "config", "--global", configKey, defaultValue); gerr != nil { + log.Fatal(4, "Fail to set git %s(%s): %s", configKey, gerr, stderr) + } + log.Info("Git config %s set to %s", configKey, defaultValue) + } else { + log.Fatal(4, "Fail to get git %s(%s): %s", configKey, err, stderr) } - if _, stderr, gerr := process.Exec("NewRepoContext(set email)", "git", "config", "--global", "user.email", stndrdUserEmail); gerr != nil { - log.Fatal(4, "Fail to set git user.email(%s): %s", gerr, stderr) - } - log.Info("Git user.name and user.email set to %s <%s>", stndrdUserName, stndrdUserEmail) - } else { - log.Fatal(4, "Fail to get git user.name(%s): %s", err, stderr) } } From f059866a2171c26c90447bf43ee6e4e03f58ecec Mon Sep 17 00:00:00 2001 From: euank Date: Sat, 27 Dec 2014 19:10:33 -0800 Subject: [PATCH 4/5] Set user.name & user.email in Dockerfile The previous setting would cause all repo creations to fail, as described in issue #328. The previous commit also resolves this issue, but it seems saner to create the user in the Dockerfile than at runtime. --- docker/blocks/docker_gogs/Dockerfile | 2 +- docker/blocks/docker_gogs_dev/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/blocks/docker_gogs/Dockerfile b/docker/blocks/docker_gogs/Dockerfile index e2e056ae02..2c98cc5011 100644 --- a/docker/blocks/docker_gogs/Dockerfile +++ b/docker/blocks/docker_gogs/Dockerfile @@ -46,7 +46,7 @@ ENV HOME /home/git ENV USER git ENV PATH $GOGS_PATH:$PATH -RUN git config --global user.name "GoGS" +RUN git config --global user.name "GoGS" && git config --global user.email "gogitservice@gmail.com" ENTRYPOINT ["/tmp/init_gogs.sh"] CMD ["gogs", "web"] diff --git a/docker/blocks/docker_gogs_dev/Dockerfile b/docker/blocks/docker_gogs_dev/Dockerfile index d1b96bf4a2..2a628c2d5e 100644 --- a/docker/blocks/docker_gogs_dev/Dockerfile +++ b/docker/blocks/docker_gogs_dev/Dockerfile @@ -47,7 +47,7 @@ ENV HOME /home/git ENV USER git ENV PATH $GOGS_PATH:$PATH -RUN git config --global user.name "GoGS" +RUN git config --global user.name "GoGS" && git config --global user.email "gogitservice@gmail.com" ENTRYPOINT ["/tmp/init_gogs.sh"] CMD ["gogs", "web"] From e948c7c262c77d41f05a3f72acd5161713cf18ef Mon Sep 17 00:00:00 2001 From: Thomas Laroche Date: Mon, 29 Dec 2014 11:55:46 +0100 Subject: [PATCH 5/5] Fix #795 --- routers/repo/setting.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/routers/repo/setting.go b/routers/repo/setting.go index aec79aa436..33bf1eab28 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -10,6 +10,7 @@ import ( "fmt" "strings" "time" + "path" "github.com/Unknwon/com" @@ -169,7 +170,7 @@ func SettingsCollaboration(ctx *middleware.Context) { ctx.Data["Title"] = ctx.Tr("repo.settings") ctx.Data["PageIsSettingsCollaboration"] = true - repoLink := strings.TrimPrefix(ctx.Repo.RepoLink, "/") + repoLink := path.Join(ctx.Repo.Owner.LowerName, ctx.Repo.Repository.LowerName) if ctx.Req.Method == "POST" { name := strings.ToLower(ctx.Query("collaborator"))