-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fixup several warnings #9009
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
base: main
Are you sure you want to change the base?
Fixup several warnings #9009
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
import SourceControl | ||
|
||
import class Basics.AsyncProcess | ||
import class TSCBasic.Process | ||
|
||
import enum TSCUtility.Git | ||
|
||
|
@@ -21,7 +22,7 @@ import enum TSCUtility.Git | |
package extension GitRepository { | ||
/// Create the repository using git init. | ||
func create() throws { | ||
try systemQuietly([Git.tool, "-C", self.path.pathString, "init"]) | ||
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "init") | ||
} | ||
|
||
/// Returns current branch name. If HEAD is on a detached state, this returns HEAD. | ||
|
@@ -38,36 +39,36 @@ package extension GitRepository { | |
|
||
/// Stage a file. | ||
func stage(file: String) throws { | ||
try systemQuietly([Git.tool, "-C", self.path.pathString, "add", file]) | ||
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "add", file) | ||
} | ||
|
||
/// Stage multiple files. | ||
func stage(files: String...) throws { | ||
try systemQuietly([Git.tool, "-C", self.path.pathString, "add"] + files) | ||
try Process.checkNonZeroExit(arguments: [Git.tool, "-C", self.path.pathString, "add"] + files) | ||
} | ||
|
||
/// Stage entire unstaged changes. | ||
func stageEverything() throws { | ||
try systemQuietly([Git.tool, "-C", self.path.pathString, "add", "."]) | ||
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "add", ".") | ||
} | ||
|
||
/// Commit the staged changes. If the message is not provided a dummy message will be used for the commit. | ||
func commit(message: String? = nil) throws { | ||
// FIXME: We don't need to set these every time but we usually only commit once or twice for a test repo. | ||
try systemQuietly([Git.tool, "-C", self.path.pathString, "config", "user.email", "[email protected]"]) | ||
try systemQuietly([Git.tool, "-C", self.path.pathString, "config", "user.name", "Example Example"]) | ||
try systemQuietly([Git.tool, "-C", self.path.pathString, "config", "commit.gpgsign", "false"]) | ||
try systemQuietly([Git.tool, "-C", self.path.pathString, "config", "tag.gpgsign", "false"]) | ||
try systemQuietly([Git.tool, "-C", self.path.pathString, "commit", "-m", message ?? "Add some files."]) | ||
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "config", "user.email", "[email protected]") | ||
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "config", "user.name", "Example Example") | ||
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "config", "commit.gpgsign", "false") | ||
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "config", "tag.gpgsign", "false") | ||
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "commit", "-m", message ?? "Add some files.") | ||
} | ||
|
||
/// Tag the git repo. | ||
func tag(name: String) throws { | ||
try systemQuietly([Git.tool, "-C", self.path.pathString, "tag", name]) | ||
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "tag", name) | ||
} | ||
|
||
/// Push the changes to specified remote and branch. | ||
func push(remote: String, branch: String) throws { | ||
try systemQuietly([Git.tool, "-C", self.path.pathString, "push", remote, branch]) | ||
try Process.checkNonZeroExit(args: Git.tool, "-C", self.path.pathString, "push", remote, branch) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,12 +32,12 @@ import Testing | |
import func XCTest.XCTFail | ||
import struct XCTest.XCTSkip | ||
|
||
import class TSCBasic.Process | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: Can we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would require marking the utility method as async and then cascading that across all its usages. Probably worth doing, but in a separate patch |
||
import struct TSCBasic.ByteString | ||
import struct Basics.AsyncProcessResult | ||
|
||
import enum TSCUtility.Git | ||
|
||
@_exported import func TSCTestSupport.systemQuietly | ||
@_exported import enum TSCTestSupport.StringPattern | ||
|
||
@available(*, deprecated, message: "Use CiEnvironment.runningInSmokeTestPipeline") | ||
|
@@ -305,7 +305,7 @@ fileprivate func setup( | |
#if os(Windows) | ||
try localFileSystem.copy(from: srcDir, to: dstDir) | ||
#else | ||
try systemQuietly("cp", "-R", "-H", srcDir.pathString, dstDir.pathString) | ||
try Process.checkNonZeroExit(args: "cp", "-R", "-H", srcDir.pathString, dstDir.pathString) | ||
#endif | ||
|
||
// Ensure we get a clean test fixture. | ||
|
@@ -361,17 +361,17 @@ public func initGitRepo( | |
try localFileSystem.writeFileContents(file, bytes: "") | ||
} | ||
|
||
try systemQuietly([Git.tool, "-C", dir.pathString, "init"]) | ||
try systemQuietly([Git.tool, "-C", dir.pathString, "config", "user.email", "[email protected]"]) | ||
try systemQuietly([Git.tool, "-C", dir.pathString, "config", "user.name", "Example Example"]) | ||
try systemQuietly([Git.tool, "-C", dir.pathString, "config", "commit.gpgsign", "false"]) | ||
try Process.checkNonZeroExit(args: Git.tool, "-C", dir.pathString, "init") | ||
try Process.checkNonZeroExit(args: Git.tool, "-C", dir.pathString, "config", "user.email", "[email protected]") | ||
try Process.checkNonZeroExit(args: Git.tool, "-C", dir.pathString, "config", "user.name", "Example Example") | ||
try Process.checkNonZeroExit(args: Git.tool, "-C", dir.pathString, "config", "commit.gpgsign", "false") | ||
let repo = GitRepository(path: dir) | ||
try repo.stageEverything() | ||
try repo.commit(message: "msg") | ||
for tag in tags { | ||
try repo.tag(name: tag) | ||
} | ||
try systemQuietly([Git.tool, "-C", dir.pathString, "branch", "-m", "main"]) | ||
try Process.checkNonZeroExit(args: Git.tool, "-C", dir.pathString, "branch", "-m", "main") | ||
} catch { | ||
XCTFail("\(error.interpolationDescription)", file: file, line: line) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: can we use
AsyncProcess
that is located in SwiftPM instead of having to rely on a TSC API?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switching from
Process.checkNonZeroExit
toAsyncProcess.checkNonZeroExit
would require many methods to be converted toasync
. While probably worthwhile, it would would be best addressed in a standalone PR.