-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Avoid name collision on fetching with appending the hash value of a dependency #2185
Conversation
Two areas of thought on this:
Edit: grammar. |
60af54e
to
d40fcec
Compare
d40fcec
to
9ac70d4
Compare
cce9143
to
dcefa9a
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.
Nice 👍
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.
Still not sure about the case-sensitivity aspects of this. 🤔
@jdhealy I'm sorry but I assume you would do the job, isn't it? Please let me know your knowledge about this atm and I may succeed that. |
dcefa9a
to
d23f94a
Compare
import Tentacle | ||
|
||
/// Uniquely identifies a project that can be used as a dependency. | ||
public enum Dependency { | ||
/// A repository hosted on GitHub.com or GitHub Enterprise. | ||
/// This is treated as case-insensitive. | ||
case gitHub(Server, Repository) |
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.
Both Server
and Repository
are case-insensitive for equality:
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.
case gitHub(Server, Repository) | ||
|
||
/// An arbitrary Git repository. | ||
/// This is treated as case-sensitive. | ||
case git(GitURL) |
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.
GitURL
's equality is based on normalizedURLString
and there is no case-insensitive comparisons or case conversions in that implementation.
Carthage/Source/CarthageKit/GitURL.swift
Lines 8 to 46 in a3573d9
/// A normalized URL string, without protocol, authentication, or port /// information. This is mostly useful for comparison, and not for any /// actual Git operations. internal var normalizedURLString: String { if let parsedURL = URL(string: urlString), let host = parsedURL.host { // Normal, valid URL. let path = strippingGitSuffix(parsedURL.path) return "\(host)\(path)" } else if urlString.hasPrefix("/") // "/path/to/..." || urlString.hasPrefix(".") // "./path/to/...", "../path/to/..." || urlString.hasPrefix("~") // "~/path/to/..." || !urlString.contains(":") // "path/to/..." with avoiding "git@github.com:owner/name" { // Local path. return strippingGitSuffix(urlString) } else { // scp syntax. var strippedURLString = urlString if let index = strippedURLString.index(of: "@") { strippedURLString.removeSubrange(strippedURLString.startIndex...index) } var host = "" if let index = strippedURLString.index(of: ":") { host = String(strippedURLString[strippedURLString.startIndex..<index]) strippedURLString.removeSubrange(strippedURLString.startIndex...index) } var path = strippingGitSuffix(strippedURLString) if !path.hasPrefix("/") { // This probably isn't strictly legit, but we'll have a forward // slash for other URL types. path.insert("/", at: path.startIndex) } return "\(host)\(path)" } } Carthage/Source/CarthageKit/GitURL.swift
Lines 64 to 66 in a3573d9
public static func == (_ lhs: GitURL, _ rhs: GitURL) -> Bool { return lhs.normalizedURLString == rhs.normalizedURLString }
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.
case git(GitURL) | ||
|
||
/// A binary-only framework | ||
/// This is treated as case-sensitive. | ||
case binary(URL) |
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.
import Foundation
URL(string: "https://google.com") == URL(string: "https://google.COM") // false
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.
This would definitely fix the issue, but I don't think it's the best approach from an end-user perspective. Switching to a fork would require a full clone of the repository. I think a better solution would be to always use the same repository for a given name, but to use a different git remote for each possible origin. For GitHub.com repositories, the name of the remote could just be the name of the owner. For other repositories, we could do essentially what you've done here. The origin approach would share the git object database across all forks, leading to faster clones and saved disk space. It would also preserve everyones' caches when they upgrade to get this PR. What do you think @ikesyo? Does that seem workable? If so, what would you think of pursuing that instead? |
@@ -27,6 +32,23 @@ public enum Dependency { | |||
} | |||
} | |||
|
|||
/// The unique identifier for this project which is useful as a file system path. | |||
public var fileSystemIdentifier: SignalProducer<String, CarthageError> { | |||
let task = Task("/usr/bin/shasum", arguments: ["-a", "256"]) |
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.
I hate shelling out for things like this. But I guess there's probably not an easy Swift option. 😞
Hmm so let’s revert #2125 for now. |
f21932a
to
a463a6e
Compare
Reopened and rebased on current |
@ikesyo What do you think of the idea I described in #2286 (comment)?
I haven't found Xcode's derived data folder, with hash-appended directories, to be very user-friendly. And although I'm sure the Xcode team would say that you don't need to navigate there, I've found that I often do need too. In other words, there's prior-art for using the hash-appended directory name, but I don't think it's particularly good art. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'd like to revisit that direction. |
Should fix #2150. Should fix #2143.
This is inspired by https://github.com/apple/swift-package-manager/blob/98cfe1cb24573341488be985fb28d6fe9ecf8920/Sources/SourceControl/Repository.swift#L23-L33.