Repository - SwiftDocOrg/Git GitHub Wiki
public final class Repository
The repository's working directory.
var commonDirectory: URL?
For example, path/to/repository/.git
.
The repository's working directory,
or nil
if the repository is bare.
var workingDirectory: URL?
For example, path/to/repository
.
The repository index, if any.
var index: Index?
The HEAD
of the repository.
var head: Head?
var attributes: Attributes
public class func open(at url: URL) throws -> Repository
public class func create(at url: URL, bare: Bool = false) throws -> Repository
public class func discover(at url: URL, acrossFileSystems: Bool = true, stoppingAt ceilingDirectories: [String] = []) throws -> Repository
@discardableResult public static func clone(from remoteURL: URL, to localURL: URL, configuration: Clone.Configuration = .default) throws -> Repository
Returns a branch by name.
public func branch(named name: String) throws -> Branch?
Returns the revision matching the provided specification.
public func revision(matching specification: String) throws -> (Commit?, Reference?)
- specification: A revision specification.
- Returns: A tuple containing the commit and/or reference matching the specification.
Calculates the number of unique revisions between two commits.
public func distance(from local: Commit, to upstream: Commit) throws -> (ahead: Int, behind: Int)
- local: The local commit.
- upstream: The upstream commit.
- Returns: A tuple with the number of commits
ahead
andbehind
.
@discardableResult public func createCommit(message: String, author: Signature? = nil, committer: Signature? = nil) throws -> Commit
Creates a lightweight tag.
public func createLightweightTag(named name: String, target: Object, force: Bool = false) throws
Creates an annotated tag.
public func createAnnotatedTag(named name: String, target: Object, tagger: Signature? = nil, message: String, force: Bool = false) throws
public func tagNames() throws -> [String]
public func tagNames(matching pattern: String) throws -> [String]
Returns a sequence of revisions according to the specified configuration.
public func revisions(with configuration: (RevisionWalker) throws -> Void) throws -> AnySequence<Commit>
- configuration: A closure whose argument can be modified to change which revisions are returned by the sequence, and the order in which they appear.
Any error that occured during configuration.
A sequence of revisions.