Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
Note: This is in reverse chronological order, so newer entries are added to the top.

Swift v.Next
-----------
-----------
* [#3310]
* Improvements

Adding a dependency requirement can now be done with the convenience initializer `.package(url: String, revision: String)`.

* [#3292]
* Improvements

Adding a dependency requirement can now be done with the convenience initializer `.package(url: String, branch: String)`.



Swift 5.4
-----------
* [#2937]
Expand Down
10 changes: 10 additions & 0 deletions Documentation/PackageDescription.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,16 @@ static func package(url: String, _ requirement: Package.Dependency.Requirement)
/// - branch: A dependency requirement. See static methods on `Package.Dependency.Requirement` for available options.
static func package(name: String? = nil, url: String, branch: String) -> Package.Dependency

/// Adds a remote package dependency given a branch requirement.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this say revision?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you're right, thanks for catching that

///
/// .package(url: "https://example.com/example-package.git", revision: "aa681bd6c61e22df0fd808044a886fc4a7ed3a65"),
///
/// - Parameters:
/// - name: The name of the package, or nil to deduce it from the URL.
/// - url: The valid Git URL of the package.
/// - revision: A dependency requirement. See static methods on `Package.Dependency.Requirement` for available options.
Comment thread
tomerd marked this conversation as resolved.
static func package(name: String? = nil, url: String, revision: String) -> Package.Dependency

/// Add a package dependency starting with a specific minimum version, up to
/// but not including a specified maximum version.
///
Expand Down
24 changes: 18 additions & 6 deletions Sources/PackageDescription/PackageDependency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,24 @@ extension Package.Dependency {
) -> Package.Dependency {
return .init(name: name, url: url, requirement: .branch(branch))
}


/// Adds a remote package dependency given a branch requirement.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this say revision?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this still say "branch" ^^

///
/// .package(url: "https://example.com/example-package.git", revision: "aa681bd6c61e22df0fd808044a886fc4a7ed3a65"),
///
/// - Parameters:
/// - name: The name of the package, or nil to deduce it from the URL.
/// - url: The valid Git URL of the package.
/// - revision: A dependency requirement. See static methods on `Package.Dependency.Requirement` for available options.
Comment thread
tomerd marked this conversation as resolved.
@available(_PackageDescription, introduced: 999.0)
public static func package(
name: String? = nil,
url: String,
revision: String
) -> Package.Dependency {
return .init(name: name, url: url, requirement: .revision(revision))
}

/// Adds a remote package dependency given a version requirement.
///
/// - Parameters:
Expand Down Expand Up @@ -266,11 +283,6 @@ extension Package.Dependency {
fatalError()
}

@available(*, unavailable, message: "use package(url:_:) with the .revision(String) initializer instead")
public static func package(url: String, revision: String) -> Package.Dependency {
fatalError()
}

@available(*, unavailable, message: "use package(url:_:) without the range label instead")
public static func package(url: String, range: Range<Version>) -> Package.Dependency {
fatalError()
Expand Down
3 changes: 2 additions & 1 deletion Tests/PackageLoadingTests/PD4_0LoadingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class PackageDescription4_0LoadingTests: PackageDescriptionLoadingTests {
.package(url: "/foo4", .exact("1.0.0")),
.package(url: "/foo5", .branch("master")),
.package(url: "/foo6", .revision("58e9de4e7b79e67c72a46e164158e3542e570ab6")),
.package(url: "/foo7", revision: "58e9de4e7b79e67c72a46e164158e3542e570ab6"),
]
)
"""
Expand All @@ -148,6 +149,7 @@ class PackageDescription4_0LoadingTests: PackageDescriptionLoadingTests {
XCTAssertEqual(deps["foo4"], .scm(location: "/foo4", requirement: .exact("1.0.0")))
XCTAssertEqual(deps["foo5"], .scm(location: "/foo5", requirement: .branch("master")))
XCTAssertEqual(deps["foo6"], .scm(location: "/foo6", requirement: .revision("58e9de4e7b79e67c72a46e164158e3542e570ab6")))
XCTAssertEqual(deps["foo7"], .scm(location: "/foo7", requirement: .revision("58e9de4e7b79e67c72a46e164158e3542e570ab6")))
}
}

Expand Down Expand Up @@ -299,7 +301,6 @@ class PackageDescription4_0LoadingTests: PackageDescriptionLoadingTests {
XCTFail("this package should not load succesfully")
} catch ManifestParseError.invalidManifestFormat(let error, _) {
XCTAssert(error.contains("error: 'package(url:version:)' is unavailable: use package(url:_:) with the .exact(Version) initializer instead\n"), "\(error)")
XCTAssert(error.contains("error: 'package(url:revision:)' is unavailable: use package(url:_:) with the .revision(String) initializer instead\n"), "\(error)")
XCTAssert(error.contains("error: 'package(url:range:)' is unavailable: use package(url:_:) without the range label instead\n"), "\(error)")
}
}
Expand Down