Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow for .package(url: , branch:) syntax #3292

Merged
merged 6 commits into from
Feb 26, 2021
Merged
Changes from 1 commit
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
22 changes: 17 additions & 5 deletions Sources/PackageDescription/PackageDependency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,23 @@ extension Package.Dependency {
) -> Package.Dependency {
return .init(name: name, url: url, requirement: .upToNextMajor(from: version))
}

/// Adds a remote package dependency given a branch requirement.
///
/// .package(url: "https://example.com/example-package.git", branch: "main"),
///
/// - Parameters:
/// - name: The name of the package, or nil to deduce it from the URL.
/// - url: The valid Git URL of the package.
/// - branch: A dependency requirement. See static methods on `Package.Dependency.Requirement` for available options.
@available(_PackageDescription, introduced: 5.3)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be 999.0 until the version number of the next release is announced.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah okay, I wasn't sure so I just did the current version, I'll take care of that and the other parts in the comment

public static func package(
name: String? = nil,
url: String,
branch: String
) -> Package.Dependency {
return .init(name: name, url: url, requirement: .branch(branch))
}

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

@available(*, unavailable, message: "use package(url:_:) with the .branch(String) initializer instead")
public static func package(url: String, branch: String) -> 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()
Expand Down