Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Repository

Hierarchy

  • Repository

Index

Constructors

constructor

Methods

readBranches

  • Read branches.

    const heads = await repo.readBranches(); // or await repo.readBranches('heads');
    const remotes = await repo.readBranches('remotes');
    const allBranches = await repo.readBranches(['heads', 'remotes']);
    console.log(heads[0].name, heads[0].commit);
    

    Parameters

    Returns Promise<Ref[]>

readBranchesSync

readCommitByBranch

  • Read a commit by branch name.

    const masterCommit = await repo.readCommitByBranch('master');
    const originMasterCommit = await repo.readCommitByBranch('origin/master');
    

    Parameters

    Returns Promise<Commit>

readCommitByBranchSync

readCommitByTag

  • readCommitByTag(tagName: string): Promise<Commit>
  • Read a commit by tag name.

    const commit = repo.readCommitByTag('v1.0');
    

    Parameters

    • tagName: string

    Returns Promise<Commit>

readCommitByTagSync

  • readCommitByTagSync(tagName: string): Commit
  • Read a commit by tag name sync.

    Parameters

    • tagName: string

    Returns Commit

readHead

  • readHead(): Promise<HEAD>
  • Read a infomation of .git/HEAD.

    const head = repo.readHead();
    // if type is 'branch'
    console.log(head.type === 'branch');
    console.log(head.branch);
    // if type is 'commit'
    console.log(head.type === 'commit);
    console.log(head.branch);
    

    Returns Promise<HEAD>

readHeadSync

  • readHeadSync(): HEAD

readTags

  • readTags(): Promise<Ref[]>
  • Read tags.

    const tags = await repo.readTags();
    

    Returns Promise<Ref[]>

readTagsSync

  • readTagsSync(): Ref[]

Static findGitDir

  • findGitDir(repositoryPath?: string): Promise<string | undefined>
  • Find a git directory. This function find one from current or parents directories.

    Parameters

    • Default value repositoryPath: string = process.cwd()

    Returns Promise<string | undefined>

Static findGitDirSync

  • findGitDirSync(repositoryPath?: string): string | undefined
  • Find a git directory sync. This function find one from current or parents directories.

    Parameters

    • Default value repositoryPath: string = process.cwd()

    Returns string | undefined

Generated using TypeDoc