-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Remove git.Command.Run
and git.Command.RunInDir*
#19280
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
65981f1
Remove `git.Command.Run*` and `git.Command.RunInDir*`
wxiaoguang 16e120b
Merge branch 'main' into refactor-git-run
wxiaoguang 142ff95
remove unnecessary `var err error`
wxiaoguang 6aa1129
remove unnecessary `var err error`
wxiaoguang ad4371c
Merge branch 'main' into refactor-git-run
wxiaoguang 3284c8a
remove unnecessary `var err error`
wxiaoguang 67ba91c
remove unnecessary `Timeout: -1` for git command, the zero value mean…
wxiaoguang 9bf48d0
rename
wxiaoguang 82f75be
Merge branch 'main' into refactor-git-run
lunny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,10 +159,11 @@ func lfsCommitAndPushTest(t *testing.T, dstPath string) (littleLFS, bigLFS strin | |
t.Skip() | ||
return | ||
} | ||
var err error | ||
prefix := "lfs-data-file-" | ||
_, err := git.NewCommand(git.DefaultContext, "lfs").AddArguments("install").RunInDir(dstPath) | ||
_, _, err = git.NewCommand(git.DefaultContext, "lfs").AddArguments("install").RunWithContextString(&git.RunContext{Dir: dstPath}) | ||
wxiaoguang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert.NoError(t, err) | ||
_, err = git.NewCommand(git.DefaultContext, "lfs").AddArguments("track", prefix+"*").RunInDir(dstPath) | ||
_, _, err = git.NewCommand(git.DefaultContext, "lfs").AddArguments("track", prefix+"*").RunWithContextString(&git.RunContext{Dir: dstPath}) | ||
assert.NoError(t, err) | ||
err = git.AddChanges(dstPath, false, ".gitattributes") | ||
assert.NoError(t, err) | ||
|
@@ -292,20 +293,20 @@ func lockTest(t *testing.T, repoPath string) { | |
} | ||
|
||
func lockFileTest(t *testing.T, filename, repoPath string) { | ||
_, err := git.NewCommand(git.DefaultContext, "lfs").AddArguments("locks").RunInDir(repoPath) | ||
_, _, err := git.NewCommand(git.DefaultContext, "lfs").AddArguments("locks").RunWithContextString(&git.RunContext{Dir: repoPath}) | ||
assert.NoError(t, err) | ||
_, err = git.NewCommand(git.DefaultContext, "lfs").AddArguments("lock", filename).RunInDir(repoPath) | ||
_, _, err = git.NewCommand(git.DefaultContext, "lfs").AddArguments("lock", filename).RunWithContextString(&git.RunContext{Dir: repoPath}) | ||
assert.NoError(t, err) | ||
_, err = git.NewCommand(git.DefaultContext, "lfs").AddArguments("locks").RunInDir(repoPath) | ||
_, _, err = git.NewCommand(git.DefaultContext, "lfs").AddArguments("locks").RunWithContextString(&git.RunContext{Dir: repoPath}) | ||
assert.NoError(t, err) | ||
_, err = git.NewCommand(git.DefaultContext, "lfs").AddArguments("unlock", filename).RunInDir(repoPath) | ||
_, _, err = git.NewCommand(git.DefaultContext, "lfs").AddArguments("unlock", filename).RunWithContextString(&git.RunContext{Dir: repoPath}) | ||
assert.NoError(t, err) | ||
} | ||
|
||
func doCommitAndPush(t *testing.T, size int, repoPath, prefix string) string { | ||
name, err := generateCommitWithNewData(size, repoPath, "[email protected]", "User Two", prefix) | ||
assert.NoError(t, err) | ||
_, err = git.NewCommand(git.DefaultContext, "push", "origin", "master").RunInDir(repoPath) // Push | ||
_, _, err = git.NewCommand(git.DefaultContext, "push", "origin", "master").RunWithContextString(&git.RunContext{Dir: repoPath}) // Push | ||
assert.NoError(t, err) | ||
return name | ||
} | ||
|
@@ -671,7 +672,8 @@ func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, baseBranch, headB | |
}) | ||
|
||
t.Run("Push", func(t *testing.T) { | ||
_, err := git.NewCommand(git.DefaultContext, "push", "origin", "HEAD:refs/for/master", "-o", "topic="+headBranch).RunInDir(dstPath) | ||
var err error | ||
wxiaoguang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
_, _, err = git.NewCommand(git.DefaultContext, "push", "origin", "HEAD:refs/for/master", "-o", "topic="+headBranch).RunWithContextString(&git.RunContext{Dir: dstPath}) | ||
if !assert.NoError(t, err) { | ||
return | ||
} | ||
|
@@ -692,7 +694,7 @@ func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, baseBranch, headB | |
assert.Contains(t, "Testing commit 1", prMsg.Body) | ||
assert.Equal(t, commit, prMsg.Head.Sha) | ||
|
||
_, err = git.NewCommand(git.DefaultContext, "push", "origin", "HEAD:refs/for/master/test/"+headBranch).RunInDir(dstPath) | ||
_, _, err = git.NewCommand(git.DefaultContext, "push", "origin", "HEAD:refs/for/master/test/"+headBranch).RunWithContextString(&git.RunContext{Dir: dstPath}) | ||
if !assert.NoError(t, err) { | ||
return | ||
} | ||
|
@@ -745,7 +747,8 @@ func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, baseBranch, headB | |
}) | ||
|
||
t.Run("Push2", func(t *testing.T) { | ||
_, err := git.NewCommand(git.DefaultContext, "push", "origin", "HEAD:refs/for/master", "-o", "topic="+headBranch).RunInDir(dstPath) | ||
var err error | ||
_, _, err = git.NewCommand(git.DefaultContext, "push", "origin", "HEAD:refs/for/master", "-o", "topic="+headBranch).RunWithContextString(&git.RunContext{Dir: dstPath}) | ||
if !assert.NoError(t, err) { | ||
return | ||
} | ||
|
@@ -757,7 +760,7 @@ func doCreateAgitFlowPull(dstPath string, ctx *APITestContext, baseBranch, headB | |
assert.Equal(t, false, prMsg.HasMerged) | ||
assert.Equal(t, commit, prMsg.Head.Sha) | ||
|
||
_, err = git.NewCommand(git.DefaultContext, "push", "origin", "HEAD:refs/for/master/test/"+headBranch).RunInDir(dstPath) | ||
_, _, err = git.NewCommand(git.DefaultContext, "push", "origin", "HEAD:refs/for/master/test/"+headBranch).RunWithContextString(&git.RunContext{Dir: dstPath}) | ||
if !assert.NoError(t, err) { | ||
return | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.