How to use the isomorphic-git.listBranches function in isomorphic-git

To help you get started, weโ€™ve selected a few isomorphic-git examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mizchi / next-editor / src / domain / git / queries / getProjectGitStatus.ts View on Github external
export async function getProjectGitStatus(
  projectRoot: string
): Promise {
  // branching
  const currentBranch = await git.currentBranch({ fs, dir: projectRoot })
  const branches = await git.listBranches({ fs, dir: projectRoot })
  const history = await getGitHistory(projectRoot, { ref: currentBranch })

  // staging
  const trackingStatus = await getGitTrackingStatus(projectRoot)
  const { tracked, untracked } = trackingStatus

  const {
    staged,
    unstaged,
    unmodified,
    rawStatusList
  } = await getFileStatusInProject(projectRoot, tracked)

  return {
    rawStatusList,
    unstaged,
github mizchi / next-editor / src / domain / git / queries / listBranches.ts View on Github external
export async function listRemoteBranches(
  projectRoot: string,
  remote: string
): Promise {
  try {
    const branches: string[] = await git.listBranches({
      dir: projectRoot,
      remote
    })
    return branches.map(b => `remotes/${remote}/${b}`)
  } catch (e) {
    // TODO: Check remote fetched once
    return []
  }
}
github elastic / kibana / x-pack / legacy / plugins / code / server / git_operations.ts View on Github external
public async getBranchAndTags(repoUri: string): Promise {
    const gitdir = this.repoDir(repoUri);
    const remoteBranches = await isogit.listBranches({ gitdir, remote: 'origin' });
    const results: ReferenceInfo[] = [];
    for (const name of remoteBranches) {
      const reference = `refs/remotes/origin/${name}`;
      const commit = await this.getCommitInfo(repoUri, reference);
      if (commit) {
        results.push({
          name,
          reference,
          type: ReferenceType.REMOTE_BRANCH,
          commit,
        });
      }
    }
    const tags = await isogit.listTags({ gitdir });
    for (const name of tags) {
      const reference = `refs/tags/${name}`;
github mizchi / next-editor / src / lib / repository.ts View on Github external
}
        default: {
          return acc
        }
      }
    },
    {
      added: [],
      modified: [],
      staged: [],
      unmodified: []
    }
  )

  const currentBranch = await git.currentBranch({ fs, dir: projectRoot })
  const branches = await git.listBranches({ fs, dir: projectRoot })
  const history = await getLogInRepository(projectRoot, { ref: currentBranch })
  return {
    branches,
    currentBranch,
    stagingStatus,
    trackingStatus,
    history
  }
}
github mizchi / next-editor / src / lib / repository.ts View on Github external
export function listBranches(projectRoot: string): Promise {
  return git.listBranches({ fs, dir: projectRoot })
}
github CleverCloud / clever-tools / src / models / git.js View on Github external
    .then((repo) => git.listBranches(repo))
    .then(autocomplete.words);
github mizchi / next-editor / src / domain / git / queries / listBranches.ts View on Github external
export function listBranches(
  projectRoot: string,
  remote: string | null = null
): Promise {
  return git.listBranches({ dir: projectRoot, remote })
}
github mizchi / next-editor / src / domain / git / queries / getBranchStatus.ts View on Github external
export async function getBranchStatus(
  projectRoot: string
): Promise<{
  currentBranch: string
  branches: string[]
  history: CommitDescription[]
  remotes: string[]
  remoteBranches: string[]
}> {
  const currentBranch = await git.currentBranch({ dir: projectRoot })
  const branches = await git.listBranches({ dir: projectRoot })
  const remotes: string[] = (await git.listRemotes({ dir: projectRoot })).map(
    (a: { remote: string; url: string }) => a.remote
  )

  const remoteBranches = flatten(
    await Promise.all(
      remotes.map(remote => listRemoteBranches(projectRoot, remote))
    )
  )

  const history = await getHistory(projectRoot, { ref: currentBranch })
  return {
    currentBranch,
    branches,
    remotes,
    remoteBranches,