From 25ec20d5251511ebd0b9e6b963e189b860c39704 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 3 Nov 2015 17:25:39 -0500 Subject: #1838 update merge base before generate new patch --- models/pull.go | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'models/pull.go') diff --git a/models/pull.go b/models/pull.go index 0300c083..56af5f82 100644 --- a/models/pull.go +++ b/models/pull.go @@ -385,16 +385,18 @@ func (pr *PullRequest) UpdateCols(cols ...string) error { var PullRequestQueue = NewUniqueQueue(setting.Repository.PullRequestQueueLength) // UpdatePatch generates and saves a new patch. -func (pr *PullRequest) UpdatePatch() error { - if err := pr.GetHeadRepo(); err != nil { +func (pr *PullRequest) UpdatePatch() (err error) { + if err = pr.GetHeadRepo(); err != nil { return fmt.Errorf("GetHeadRepo: %v", err) } else if pr.HeadRepo == nil { log.Trace("PullRequest[%d].UpdatePatch: ignored cruppted data", pr.ID) return nil } - if err := pr.GetBaseRepo(); err != nil { + if err = pr.GetBaseRepo(); err != nil { return fmt.Errorf("GetBaseRepo: %v", err) + } else if err = pr.BaseRepo.GetOwner(); err != nil { + return fmt.Errorf("GetOwner: %v", err) } headRepoPath, err := pr.HeadRepo.RepoPath() @@ -407,6 +409,22 @@ func (pr *PullRequest) UpdatePatch() error { return fmt.Errorf("OpenRepository: %v", err) } + // Add a temporary remote. + tmpRemote := com.ToStr(time.Now().UnixNano()) + if err = headGitRepo.AddRemote(tmpRemote, RepoPath(pr.BaseRepo.Owner.Name, pr.BaseRepo.Name)); err != nil { + return fmt.Errorf("AddRemote: %v", err) + } + defer func() { + headGitRepo.RemoveRemote(tmpRemote) + }() + remoteBranch := "remotes/" + tmpRemote + "/" + pr.BaseBranch + pr.MergeBase, err = headGitRepo.GetMergeBase(remoteBranch, pr.HeadBranch) + if err != nil { + return fmt.Errorf("GetMergeBase: %v", err) + } else if err = pr.Update(); err != nil { + return fmt.Errorf("Update: %v", err) + } + patch, err := headGitRepo.GetPatch(pr.MergeBase, pr.HeadBranch) if err != nil { return fmt.Errorf("GetPatch: %v", err) -- cgit v1.2.3 From 4f03b81ec777813820d4e33ec11893e214ec27d2 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sun, 15 Nov 2015 14:41:36 -0500 Subject: #1931 Test patch does not checkout correct base branch --- models/pull.go | 11 ++++++++++- models/repo.go | 2 +- modules/middleware/repo.go | 1 - templates/repo/sidebar.tmpl | 6 ++++-- 4 files changed, 15 insertions(+), 5 deletions(-) (limited to 'models/pull.go') diff --git a/models/pull.go b/models/pull.go index 56af5f82..094cb9b2 100644 --- a/models/pull.go +++ b/models/pull.go @@ -218,6 +218,7 @@ var patchConflicts = []string{ } // testPatch checks if patch can be merged to base repository without conflit. +// FIXME: make a mechanism to clean up stable local copies. func (pr *PullRequest) testPatch() (err error) { if pr.BaseRepo == nil { pr.BaseRepo, err = GetRepositoryByID(pr.BaseRepoID) @@ -243,8 +244,16 @@ func (pr *PullRequest) testPatch() (err error) { return fmt.Errorf("UpdateLocalCopy: %v", err) } - pr.Status = PULL_REQUEST_STATUS_CHECKING + // Checkout base branch. _, stderr, err := process.ExecDir(-1, pr.BaseRepo.LocalCopyPath(), + fmt.Sprintf("PullRequest.Merge(git checkout): %s", pr.BaseRepo.ID), + "git", "checkout", pr.BaseBranch) + if err != nil { + return fmt.Errorf("git checkout: %s", stderr) + } + + pr.Status = PULL_REQUEST_STATUS_CHECKING + _, stderr, err = process.ExecDir(-1, pr.BaseRepo.LocalCopyPath(), fmt.Sprintf("testPatch(git apply --check): %d", pr.BaseRepo.ID), "git", "apply", "--check", patchPath) if err != nil { diff --git a/models/repo.go b/models/repo.go index fab463b9..bbd978ff 100644 --- a/models/repo.go +++ b/models/repo.go @@ -320,7 +320,7 @@ func (repo *Repository) UpdateLocalCopy() error { } } else { _, stderr, err := process.ExecDir(-1, localPath, - fmt.Sprintf("UpdateLocalCopy(git pull): %s", repoPath), "git", "pull") + fmt.Sprintf("UpdateLocalCopy(git pull --all): %s", repoPath), "git", "pull", "--all") if err != nil { return fmt.Errorf("git pull: %v - %s", err, stderr) } diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index afa95a25..c7481743 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -81,7 +81,6 @@ func RepoRef() macaron.Handler { return func(ctx *Context) { // Empty repository does not have reference information. if ctx.Repo.Repository.IsBare { - ctx.Data["CommitsCount"] = 0 return } diff --git a/templates/repo/sidebar.tmpl b/templates/repo/sidebar.tmpl index df033c0e..2e4fdfb6 100644 --- a/templates/repo/sidebar.tmpl +++ b/templates/repo/sidebar.tmpl @@ -1,4 +1,5 @@ - +{{end}} \ No newline at end of file -- cgit v1.2.3 From e06558e2083e6281500cc1c91ac54425b91390fe Mon Sep 17 00:00:00 2001 From: Unknwon Date: Mon, 16 Nov 2015 21:18:04 -0500 Subject: #1922 Pull request fail to merge with BIN --- README.md | 2 +- gogs.go | 2 +- models/pull.go | 1 + modules/git/repo_pull.go | 2 +- templates/.VERSION | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) (limited to 'models/pull.go') diff --git a/README.md b/README.md index 1e363ded..c649a382 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra ![](public/img/gogs-large-resize.png) -##### Current version: 0.7.13 Beta +##### Current version: 0.7.14 Beta diff --git a/gogs.go b/gogs.go index f8a39f3f..80f780e8 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.7.13.1116 Beta" +const APP_VER = "0.7.14.1116 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/pull.go b/models/pull.go index 094cb9b2..5c7d4a3f 100644 --- a/models/pull.go +++ b/models/pull.go @@ -260,6 +260,7 @@ func (pr *PullRequest) testPatch() (err error) { for i := range patchConflicts { if strings.Contains(stderr, patchConflicts[i]) { log.Trace("PullRequest[%d].testPatch(apply): has conflit", pr.ID) + fmt.Println(stderr) pr.Status = PULL_REQUEST_STATUS_CONFLICT return nil } diff --git a/modules/git/repo_pull.go b/modules/git/repo_pull.go index 16b9536f..f9ea7100 100644 --- a/modules/git/repo_pull.go +++ b/modules/git/repo_pull.go @@ -89,7 +89,7 @@ func (repo *Repository) GetPullRequestInfo(basePath, baseBranch, headBranch stri // GetPatch generates and returns patch data between given branches. func (repo *Repository) GetPatch(mergeBase, headBranch string) ([]byte, error) { - stdout, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "diff", "-p", mergeBase, headBranch) + stdout, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "diff", "-p", "--binary", mergeBase, headBranch) if err != nil { return nil, concatenateError(err, string(stderr)) } diff --git a/templates/.VERSION b/templates/.VERSION index 87a10ba3..b0072b13 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.7.13.1116 Beta \ No newline at end of file +0.7.14.1116 Beta \ No newline at end of file -- cgit v1.2.3 From 1d4a5b1825e46b51a1cbd6dc5d24a4ea585a0e72 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 20 Nov 2015 02:53:54 -0500 Subject: fix #2002 --- models/pull.go | 30 ++++++++++++++++++------------ models/release.go | 2 +- models/repo.go | 8 ++++---- 3 files changed, 23 insertions(+), 17 deletions(-) (limited to 'models/pull.go') diff --git a/models/pull.go b/models/pull.go index 5c7d4a3f..e67d242e 100644 --- a/models/pull.go +++ b/models/pull.go @@ -166,43 +166,49 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error var stderr string if _, stderr, err = process.ExecTimeout(5*time.Minute, - fmt.Sprintf("PullRequest.Merge(git clone): %s", tmpBasePath), + fmt.Sprintf("PullRequest.Merge (git clone): %s", tmpBasePath), "git", "clone", baseGitRepo.Path, tmpBasePath); err != nil { return fmt.Errorf("git clone: %s", stderr) } // Check out base branch. if _, stderr, err = process.ExecDir(-1, tmpBasePath, - fmt.Sprintf("PullRequest.Merge(git checkout): %s", tmpBasePath), + fmt.Sprintf("PullRequest.Merge (git checkout): %s", tmpBasePath), "git", "checkout", pr.BaseBranch); err != nil { return fmt.Errorf("git checkout: %s", stderr) } // Add head repo remote. if _, stderr, err = process.ExecDir(-1, tmpBasePath, - fmt.Sprintf("PullRequest.Merge(git remote add): %s", tmpBasePath), + fmt.Sprintf("PullRequest.Merge (git remote add): %s", tmpBasePath), "git", "remote", "add", "head_repo", headRepoPath); err != nil { - return fmt.Errorf("git remote add[%s -> %s]: %s", headRepoPath, tmpBasePath, stderr) + return fmt.Errorf("git remote add [%s -> %s]: %s", headRepoPath, tmpBasePath, stderr) } // Merge commits. if _, stderr, err = process.ExecDir(-1, tmpBasePath, - fmt.Sprintf("PullRequest.Merge(git fetch): %s", tmpBasePath), + fmt.Sprintf("PullRequest.Merge (git fetch): %s", tmpBasePath), "git", "fetch", "head_repo"); err != nil { - return fmt.Errorf("git fetch[%s -> %s]: %s", headRepoPath, tmpBasePath, stderr) + return fmt.Errorf("git fetch [%s -> %s]: %s", headRepoPath, tmpBasePath, stderr) } if _, stderr, err = process.ExecDir(-1, tmpBasePath, - fmt.Sprintf("PullRequest.Merge(git merge): %s", tmpBasePath), - "git", "merge", "--no-ff", "-m", - fmt.Sprintf("Merge branch '%s' of %s/%s into %s", pr.HeadBranch, pr.HeadUserName, pr.HeadRepo.Name, pr.BaseBranch), - "head_repo/"+pr.HeadBranch); err != nil { - return fmt.Errorf("git merge[%s]: %s", tmpBasePath, stderr) + fmt.Sprintf("PullRequest.Merge (git merge --no-commit): %s", tmpBasePath), + "git", "merge", "--no-commit", "head_repo/"+pr.HeadBranch); err != nil { + return fmt.Errorf("git merge --no-commit [%s]: %s", tmpBasePath, stderr) + } + + sig := doer.NewGitSig() + if _, stderr, err = process.ExecDir(-1, tmpBasePath, + fmt.Sprintf("PullRequest.Merge (git merge): %s", tmpBasePath), + "git", "commit", fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email), + "-m", fmt.Sprintf("Merge branch '%s' of %s/%s into %s", pr.HeadBranch, pr.HeadUserName, pr.HeadRepo.Name, pr.BaseBranch)); err != nil { + return fmt.Errorf("git commit [%s]: %s", tmpBasePath, stderr) } // Push back to upstream. if _, stderr, err = process.ExecDir(-1, tmpBasePath, - fmt.Sprintf("PullRequest.Merge(git push): %s", tmpBasePath), + fmt.Sprintf("PullRequest.Merge (git push): %s", tmpBasePath), "git", "push", baseGitRepo.Path, pr.BaseBranch); err != nil { return fmt.Errorf("git push: %s", stderr) } diff --git a/models/release.go b/models/release.go index 8b98f0b8..ef1d640d 100644 --- a/models/release.go +++ b/models/release.go @@ -180,7 +180,7 @@ func DeleteReleaseByID(id int64) error { return fmt.Errorf("RepoPath: %v", err) } - _, stderr, err := process.ExecDir(-1, repoPath, fmt.Sprintf("Delete release [%d]", rel.ID), + _, stderr, err := process.ExecDir(-1, repoPath, fmt.Sprintf("DeleteReleaseByID (git tag -d): %d", rel.ID), "git", "tag", "-d", rel.TagName) if err != nil && !strings.Contains(stderr, "not found") { return fmt.Errorf("git tag -d: %v - %s", err, stderr) diff --git a/models/repo.go b/models/repo.go index 80009409..cc7bde3a 100644 --- a/models/repo.go +++ b/models/repo.go @@ -576,20 +576,20 @@ func MigrateRepository(u *User, opts MigrateRepoOptions) (*Repository, error) { func initRepoCommit(tmpPath string, sig *git.Signature) (err error) { var stderr string if _, stderr, err = process.ExecDir(-1, - tmpPath, fmt.Sprintf("initRepoCommit(git add): %s", tmpPath), + tmpPath, fmt.Sprintf("initRepoCommit (git add): %s", tmpPath), "git", "add", "--all"); err != nil { return fmt.Errorf("git add: %s", stderr) } if _, stderr, err = process.ExecDir(-1, - tmpPath, fmt.Sprintf("initRepoCommit(git commit): %s", tmpPath), + tmpPath, fmt.Sprintf("initRepoCommit (git commit): %s", tmpPath), "git", "commit", fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email), "-m", "initial commit"); err != nil { return fmt.Errorf("git commit: %s", stderr) } if _, stderr, err = process.ExecDir(-1, - tmpPath, fmt.Sprintf("initRepoCommit(git push): %s", tmpPath), + tmpPath, fmt.Sprintf("initRepoCommit (git push): %s", tmpPath), "git", "push", "origin", "master"); err != nil { return fmt.Errorf("git push: %s", stderr) } @@ -700,7 +700,7 @@ func initRepository(e Engine, repoPath string, u *User, repo *Repository, opts C // Init bare new repository. os.MkdirAll(repoPath, os.ModePerm) _, stderr, err := process.ExecDir(-1, repoPath, - fmt.Sprintf("initRepository(git init --bare): %s", repoPath), "git", "init", "--bare") + fmt.Sprintf("initRepository (git init --bare): %s", repoPath), "git", "init", "--bare") if err != nil { return fmt.Errorf("git init --bare: %v - %s", err, stderr) } -- cgit v1.2.3 From 74dfe439c23420f22d1c893733bbde48d6aad4ca Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 20 Nov 2015 04:08:08 -0500 Subject: more fix on #2002 --- models/pull.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'models/pull.go') diff --git a/models/pull.go b/models/pull.go index e67d242e..587a959d 100644 --- a/models/pull.go +++ b/models/pull.go @@ -194,8 +194,8 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error if _, stderr, err = process.ExecDir(-1, tmpBasePath, fmt.Sprintf("PullRequest.Merge (git merge --no-commit): %s", tmpBasePath), - "git", "merge", "--no-commit", "head_repo/"+pr.HeadBranch); err != nil { - return fmt.Errorf("git merge --no-commit [%s]: %s", tmpBasePath, stderr) + "git", "merge", "--no-ff", "--no-commit", "head_repo/"+pr.HeadBranch); err != nil { + return fmt.Errorf("git merge --no-ff --no-commit [%s]: %s", tmpBasePath, stderr) } sig := doer.NewGitSig() @@ -203,7 +203,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error fmt.Sprintf("PullRequest.Merge (git merge): %s", tmpBasePath), "git", "commit", fmt.Sprintf("--author='%s <%s>'", sig.Name, sig.Email), "-m", fmt.Sprintf("Merge branch '%s' of %s/%s into %s", pr.HeadBranch, pr.HeadUserName, pr.HeadRepo.Name, pr.BaseBranch)); err != nil { - return fmt.Errorf("git commit [%s]: %s", tmpBasePath, stderr) + return fmt.Errorf("git commit [%s]: %v - %s", tmpBasePath, err, stderr) } // Push back to upstream. -- cgit v1.2.3 From 6b30b20765e0895bae8ee957fdd08c0e2853329a Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 20 Nov 2015 08:43:15 -0500 Subject: add more debug info --- models/pull.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'models/pull.go') diff --git a/models/pull.go b/models/pull.go index 587a959d..f5f36302 100644 --- a/models/pull.go +++ b/models/pull.go @@ -195,7 +195,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error if _, stderr, err = process.ExecDir(-1, tmpBasePath, fmt.Sprintf("PullRequest.Merge (git merge --no-commit): %s", tmpBasePath), "git", "merge", "--no-ff", "--no-commit", "head_repo/"+pr.HeadBranch); err != nil { - return fmt.Errorf("git merge --no-ff --no-commit [%s]: %s", tmpBasePath, stderr) + return fmt.Errorf("git merge --no-ff --no-commit [%s]: %v - %s", tmpBasePath, err, stderr) } sig := doer.NewGitSig() -- cgit v1.2.3 From 6a6a7512c2c85f6e8ec485f8ae1ed290c6730134 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 20 Nov 2015 11:37:17 -0500 Subject: notice --- README.md | 3 ++- models/pull.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'models/pull.go') diff --git a/README.md b/README.md index e9321e1b..0236fdaa 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,8 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra - Due to testing purpose, data of [try.gogs.io](https://try.gogs.io) has been reset in **Jan 28, 2015** and will reset multiple times after. Please do **NOT** put your important data on the site. - The demo site [try.gogs.io](https://try.gogs.io) is running under `develop` branch. -- :bangbang:You **MUST** read [CONTRIBUTING.md](CONTRIBUTING.md) before you start filing an issue or making a Pull Request, and **MUST** discuss with us on [Gitter](https://gitter.im/gogits/gogs) for UI changes and feature Pull Requests, otherwise it's high possibilities that we are not going to merge it.:bangbang: +- :bangbang:You **MUST** read [CONTRIBUTING.md](CONTRIBUTING.md) before you start filing an issue or making a Pull Request, and **MUST** discuss with us on [Gitter](https://gitter.im/gogits/gogs) for UI changes, otherwise it's high possibilities that we are not going to merge it.:bangbang: +- Please [start discussion](http://forum.gogs.io/category/2/general-discussion) or [ask a question](http://forum.gogs.io/category/4/getting-help) on [the forum](http://forum.gogs.io/). GitHub issue tracker only keeps **bugs** and **feature requests**, all other topics will be closed without reason. - If you think there are vulnerabilities in the project, please talk privately to **u@gogs.io**. Thanks! - If you're interested in using APIs, we have experimental support with [documentation](https://github.com/gogits/go-gogs-client/wiki). - If your team/company is using Gogs and would like to put your logo on [our website](http://gogs.io), contact us by any means. diff --git a/models/pull.go b/models/pull.go index f5f36302..dfd80635 100644 --- a/models/pull.go +++ b/models/pull.go @@ -193,7 +193,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error } if _, stderr, err = process.ExecDir(-1, tmpBasePath, - fmt.Sprintf("PullRequest.Merge (git merge --no-commit): %s", tmpBasePath), + fmt.Sprintf("PullRequest.Merge (git merge --no-ff --no-commit): %s", tmpBasePath), "git", "merge", "--no-ff", "--no-commit", "head_repo/"+pr.HeadBranch); err != nil { return fmt.Errorf("git merge --no-ff --no-commit [%s]: %v - %s", tmpBasePath, err, stderr) } -- cgit v1.2.3