-
Notifications
You must be signed in to change notification settings - Fork 1.4k
validate local repository has the correct remote #7079
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
Conversation
@MaxDesiatov @neonichu @shahmishal this would now emit warnings in the edge case we ran into where the local repositories in .build became invalid |
@@ -210,6 +210,11 @@ public struct GitRepositoryProvider: RepositoryProvider, Cancellable { | |||
return result == ".git" || result == "." || result == directory.pathString | |||
} | |||
|
|||
public func isValidDirectory(_ directory: Basics.AbsolutePath, for repository: RepositorySpecifier) throws -> Bool { | |||
let remoteURL = try self.git.run(["-C", directory.pathString, "remote", "get-url", "origin"]) |
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.
will the remote always be origin
? (just wondering)
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.
yes iiuc, in this case it us the one that SwiftPM sets
motivation: in some edge cases, the local repository may be partially valid (the containing directory is a legit git repo, but the repository diretory is not), or otherwise point to a remote different than the one expected changes: * validate that the local reposiotry remote aligns with the expected one, not just that the directory is a valid git repo * refactor validation flow to be more streamlined
9da2275
to
601fbd2
Compare
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.
Can we have a test for this? Maybe some preset fixture that reproduces what we've seen, or we could create a new corrupted git repository in a temp directory during the test?
yea i am planning to add a test |
@swift-ci test |
@swift-ci test windows |
@neonichu based on our discussion yesterday, is this good to go? |
Yah, I think so. |
Base branch was modified
motivation: in some edge cases, the local repository may be partially valid (the containing directory is a legit git repo, but the repository directory is not), or otherwise point to a remote different than the one expected changes: * validate that the local repository remote aligns with the expected one, not just that the directory is a valid git repo * refactor validation flow to be more streamlined
motivation: in some edge cases, the local repository may be partially valid (the containing directory is a legit git repo, but the repository directory is not), or otherwise point to a remote different than the one expected changes: * validate that the local repository remote aligns with the expected one, not just that the directory is a valid git repo * refactor validation flow to be more streamlined
motivation: in some edge cases, the local repository may be partially valid (the containing directory is a legit git repo, but the repository directory is not), or otherwise point to a remote different than the one expected
changes: