Skip to content

Commit 19300a9

Browse files
committed
fix typo, better test
1 parent 9f05a63 commit 19300a9

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

services/agit/agit.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,19 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git.
5555
}
5656

5757
baseBranchName := opts.RefFullNames[i].ForBranchName()
58-
curentTopicBranch := ""
58+
currentTopicBranch := ""
5959
if !gitRepo.IsBranchExist(baseBranchName) {
6060
// try match refs/for/<target-branch>/<topic-branch>
6161
for p, v := range baseBranchName {
6262
if v == '/' && gitRepo.IsBranchExist(baseBranchName[:p]) && p != len(baseBranchName)-1 {
63-
curentTopicBranch = baseBranchName[p+1:]
63+
currentTopicBranch = baseBranchName[p+1:]
6464
baseBranchName = baseBranchName[:p]
6565
break
6666
}
6767
}
6868
}
6969

70-
if len(topicBranch) == 0 && len(curentTopicBranch) == 0 {
70+
if len(topicBranch) == 0 && len(currentTopicBranch) == 0 {
7171
results = append(results, private.HookProcReceiveRefResult{
7272
OriginalRef: opts.RefFullNames[i],
7373
OldOID: opts.OldCommitIDs[i],
@@ -77,18 +77,18 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git.
7777
continue
7878
}
7979

80-
if len(curentTopicBranch) == 0 {
81-
curentTopicBranch = topicBranch
80+
if len(currentTopicBranch) == 0 {
81+
currentTopicBranch = topicBranch
8282
}
8383

8484
// because different user maybe want to use same topic,
8585
// So it's better to make sure the topic branch name
86-
// has user name prefix
86+
// has username prefix
8787
var headBranch string
88-
if !strings.HasPrefix(curentTopicBranch, userName+"/") {
89-
headBranch = userName + "/" + curentTopicBranch
88+
if !strings.HasPrefix(currentTopicBranch, userName+"/") {
89+
headBranch = userName + "/" + currentTopicBranch
9090
} else {
91-
headBranch = curentTopicBranch
91+
headBranch = currentTopicBranch
9292
}
9393

9494
pr, err := issues_model.GetUnmergedPullRequest(ctx, repo.ID, repo.ID, headBranch, baseBranchName, issues_model.PullRequestFlowAGit)

tests/integration/git_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,11 +966,17 @@ func TestAgitPullPush(t *testing.T) {
966966
assert.NoError(t, err)
967967

968968
// push to create an agit pull request
969-
err = git.NewCommand(git.DefaultContext, "push", "origin", "HEAD:refs/for/master/test-agit-push").Run(&git.RunOpts{Dir: dstPath})
969+
err = git.NewCommand(git.DefaultContext, "push", "origin",
970+
"-o", "title=test-title", "-o", "description=test-description",
971+
"HEAD:refs/for/master/test-agit-push",
972+
).Run(&git.RunOpts{Dir: dstPath})
970973
assert.NoError(t, err)
971974

972975
// check pull request exist
973-
unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{BaseRepoID: 1, Flow: issues_model.PullRequestFlowAGit, HeadBranch: "user2/test-agit-push"})
976+
pr := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{BaseRepoID: 1, Flow: issues_model.PullRequestFlowAGit, HeadBranch: "user2/test-agit-push"})
977+
assert.NoError(t, pr.LoadIssue(db.DefaultContext))
978+
assert.Equal(t, "test-title", pr.Issue.Title)
979+
assert.Equal(t, "test-description", pr.Issue.Content)
974980

975981
// commit 2
976982
_, err = generateCommitWithNewData(littleSize, dstPath, "[email protected]", "User Two", "branch-data-file-2-")

0 commit comments

Comments
 (0)