Skip to content
This repository has been archived by the owner on Oct 17, 2021. It is now read-only.

Repository

mattt edited this page Jul 27, 2020 · 9 revisions

Repository

public final class Repository

Initializers

init(_:)

init(_ pointer: OpaquePointer)

init(_:)

public init(_ url: URL) throws

Properties

pointer

var pointer: OpaquePointer!

managed

var managed: Bool

commonDirectory

The repository's working directory.

var commonDirectory: URL?

For example, path/to/repository/.git.

workingDirectory

The repository's working directory, or nil if the repository is bare.

var workingDirectory: URL?

For example, path/to/repository.

index

The repository index, if any.

var index: Index?

head

The HEAD of the repository.

var head: Head?

Methods

create(at:bare:)

public class func create(at url: URL, bare: Bool = false) throws -> Repository

branch(named:)

Returns a branch by name.

public func branch(named name: String) throws -> Branch?

lookup(_:)

Lookup an object by ID.

public func lookup<T: Object>(_ id: Object.ID) throws -> T?

Parameters

  • id: - id: The object ID.

Throws

An error if no object exists for the

Returns

The corresponding object.

revision(matching:)

Returns the revision matching the provided specification.

public func revision(matching specification: String) throws -> (Commit?, Reference?)

Parameters

  • specification: - specification: A revision specification.

Returns

A tuple containing the commit and/or reference matching the specification.

distance(from:to:)

Calculates the number of unique revisions between two commits.

public func distance(from local: Commit, to upstream: Commit) throws -> (ahead: Int, behind: Int)

Parameters

  • local: - local: The local commit.
  • upstream: - upstream: The upstream commit.

Returns

A tuple with the number of commits ahead and behind.

revisions(with:)

Returns a sequence of revisions according to the specified configuration.

public func revisions(with configuration: (RevisionWalker) throws -> Void) throws -> AnySequence<Commit>

Parameters

  • configuration: - configuration: A closure whose argument can be modified to change which revisions are returned by the sequence, and the order in which they appear.

Throws

Any error that occured during configuration.

Returns

A sequence of revisions.

Clone this wiki locally