Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when merge pull request #6946

Closed
2 of 7 tasks
zongwei007 opened this issue May 14, 2019 · 14 comments · Fixed by #6961
Closed
2 of 7 tasks

Error when merge pull request #6946

zongwei007 opened this issue May 14, 2019 · 14 comments · Fixed by #6961
Labels
Milestone

Comments

@zongwei007
Copy link

  • Gitea version (or commit ref): 1.9.0+dev-249-g8b36f01f4
  • Git version: 2.20.1
  • Operating system: docker
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:
2019/05/14 12:11:57 ...orm/session_exist.go:79:Exist() [I] [SQL] SELECT "id", "org_id", "team_id", "uid" FROM "team_user" WHERE (uid=$1) AND "team_id" IN ($2) LIMIT 1 []interface {}{2, 28},
[Macaron] 2019-05-14 12:11:57: Started GET /api/internal/branch/69/master for 127.0.0.1,
2019/05/14 12:11:57 modules/auth/auth.go:97:CheckOAuthAccessToken() [T] ParseOAuth2Token: signature is invalid,
2019/05/14 12:11:57 ...s/context/context.go:308:func1() [D] Session ID: dad04db9e123606d,
2019/05/14 12:11:57 ...s/context/context.go:309:func1() [D] CSRF Token: o5QUfe4WWRuQbs-M3v_LlmRjt2I6MTU1NzgzNTkxNzIxMTM1MDExMA==,
2019/05/14 12:11:57 .../xorm/session_get.go:95:nocacheGet() [I] [SQL] SELECT "id", "repo_id", "branch_name", "can_push", "enable_whitelist", "whitelist_user_i_ds", "whitelist_team_i_ds", "enable_merge_whitelist", "merge_whitelist_user_i_ds", "merge_whitelist_team_i_ds", "approvals_whitelist_user_i_ds", "approvals_whitelist_team_i_ds", "required_approvals", "created_unix", "updated_unix" FROM "protected_branch" WHERE "repo_id"=$1 AND "branch_name"=$2 LIMIT 1 []interface {}{69, "master"},
2019/05/14 12:11:57 routers/repo/pull.go:605:MergePullRequest() [E] Merge: git push: From /data/git/repositories/project/shell-asset,
[Macaron] 2019-05-14 12:11:57: Completed GET /api/internal/branch/69/master 200 OK in 2.41096ms,
	 * [new branch]      feat_archive -> head_repo/feat_archive,
	 * [new branch]      fixBug       -> head_repo/fixBug,
	 * [new branch]      master       -> head_repo/master,
	Automatic merge went well; stopped before committing as requested,
	remote: Gitea: Internal error        ,
	remote: Fail to detect force push: chdir /data/git/repositories/shell-asset.git: no such file or directory        ,
	To /data/git/repositories/project/shell-asset.git,
	 ! [remote rejected] master -> master (pre-receive hook declined),
	error: failed to push some refs to '/data/git/repositories/project/shell-asset.git',
2019/05/14 12:11:57 models/webhook.go:867:DeliverHooks() [T] DeliverHooks [repo_id: 69],
2019/05/14 12:11:57 ...s/context/context.go:138:HTML() [D] Template: status/500,
2019/05/14 12:11:57 models/pull.go:1298:AddTestPullRequestTask() [T] AddTestPullRequestTask [head_repo_id: 69, head_branch: master]: finding pull requests,
[Macaron] 2019-05-14 12:11:57: Completed POST /Project/Shell-Asset/pulls/83/merge 500 Internal Server Error in 158.425011ms

Description

When I merge a pull request of repository Project/Shell-Asset, I got a 500 error. Project is a private organization and shell-asset is private repository also. I disabled git hook from app.ini but does not work.

@lafriks
Copy link
Member

lafriks commented May 14, 2019

Have you changed git repository storage directory? Are you using docker?

@zongwei007
Copy link
Author

@lafriks Yes. I use gitea with docker. data volume mounted on host and no changed recently.

@ihuro
Copy link

ihuro commented May 15, 2019

Same issue, but only on protected branches.
I use docker too.

@lafriks
Copy link
Member

lafriks commented May 15, 2019

This could be related to this change #6608

@zongwei007
Copy link
Author

Same as @ihuro , it can do merge successfully if I close the protection of master branch.

@lunny
Copy link
Member

lunny commented May 15, 2019

Which merge style did you use?

@lafriks
Copy link
Member

lafriks commented May 15, 2019

Looks like it is caused by #6672 as now hooks are checking branch protection also for PR merges, cc @zeripath

@zeripath
Copy link
Contributor

Agh! Sorry about this!

@lafriks we can detect quite easily whether a push is being performed by gitea internally by checking the SSH_ORIGINAL_COMMAND which is set to gitea-internal if it's a gitea push etc. So we could remove protected branch checking if that's set - however, maybe we can do better.

(I think there's actually another issue in #6672 - whereby:

gitea/models/pull.go

Lines 622 to 636 in 7dd9837

p := &api.PushPayload{
Ref: git.BranchPrefix + pr.BaseBranch,
Before: pr.MergeBase,
After: mergeCommit.ID.String(),
CompareURL: setting.AppURL + pr.BaseRepo.ComposeCompareURL(pr.MergeBase, pr.MergedCommitID),
Commits: ListToPushCommits(l).ToAPIPayloadCommits(pr.BaseRepo.HTMLURL()),
Repo: pr.BaseRepo.APIFormat(mode),
Pusher: pr.HeadRepo.MustOwner().APIFormat(),
Sender: doer.APIFormat(),
}
if err = PrepareWebhooks(pr.BaseRepo, HookEventPush, p); err != nil {
log.Error("PrepareWebhooks: %v", err)
} else {
go HookQueue.Add(pr.BaseRepo.ID)
}

Might be sending double hooks.)

I'll take a look. Sorry once again.

@zeripath
Copy link
Contributor

OK, I think what we should do is to set (another) environment variable with the PR number we're merging - that will allow people to have hooks that detect PR merges.

@lunny
Copy link
Member

lunny commented May 17, 2019

This affected only when running gitea on docker

@lunny
Copy link
Member

lunny commented May 17, 2019

chdir /data/git/repositories/shell-asset.git: no such file or directory        ,
	To /data/git/repositories/project/shell-asset.git

It seems because the repoUserName env was blank.

@lunny
Copy link
Member

lunny commented May 17, 2019

@zongwei007 could you confirm that #6971 will fix this issue?

@zongwei007
Copy link
Author

@lunny merge successfully on 1.9.0+dev-262-g96b412bb8.

@lunny
Copy link
Member

lunny commented May 19, 2019

@zongwei007 OK.

@lunny lunny closed this as completed May 19, 2019
zeripath added a commit to zeripath/gitea that referenced this issue May 21, 2019
lunny pushed a commit that referenced this issue Jul 1, 2019
* Fix #6946 by checking PullRequest ID on pushing

* Ensure we have the owner name, the pr attributes and the the issue

* Fix TestSearchRepo by waiting till indexing is done

* Update integrations/repo_search_test.go

* changes as per @mrsdizzie

* missing comma

* Spelling mistake

* Fix full pushing environment
jeffliu27 pushed a commit to jeffliu27/gitea that referenced this issue Jul 18, 2019
go-gitea#6961)

* Fix go-gitea#6946 by checking PullRequest ID on pushing

* Ensure we have the owner name, the pr attributes and the the issue

* Fix TestSearchRepo by waiting till indexing is done

* Update integrations/repo_search_test.go

* changes as per @mrsdizzie

* missing comma

* Spelling mistake

* Fix full pushing environment
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
5 participants