parent |
---|
Development API |
Writes a commit to the local Git repository.
import { Git } from 'skuba';
await Git.commit({ dir, message: 'Test a commit' });
Stages all changes and writes a commit to the local Git repository.
Skips the commit and returns undefined
if there are no changes.
import { Git } from 'skuba';
await Git.commitAllChanges({ dir, message: 'Test a commit' });
Tries to return a Git branch name from CI environment variables,
falling back to the local Git repository when the current working dir
is supplied.
import { Git } from 'skuba';
const currentBranch = Git.currentBranch({ dir });
Fast forwards the specified ref
on the local Git repository to match the remote branch.
Currently, only GitHub app tokens are supported as an auth mechanism.
import { Git } from 'skuba';
await Git.fastForwardBranch({
auth: { type: 'gitHubApp' },
dir,
ref: 'branch-name',
});
Returns all the files which have been added, modified or deleted in the working directory of the local Git repository since the last commit.
import { Git } from 'skuba';
const changedFiles = await Git.getChangedFiles({ dir });
Gets the object ID of the head commit.
This tries to extract the commit ID from common CI environment variables, and falls back to the local Git repository log.
import { Git } from 'skuba';
const headCommitId = await Git.getHeadCommitId({ dir });
Gets the message of the head commit.
This tries to extract the message from common CI environment variables, and falls back to the local Git repository log.
import { Git } from 'skuba';
const headCommitMessage = await Git.getHeadCommitMessage({ dir });
Extracts the owner and repository names from CI environment variables, falling back to local Git remotes.
Currently, only GitHub repository URLs are supported:
[email protected]:seek-oss/skuba.git
https://github.com/seek-oss/skuba.git
import { Git } from 'skuba';
const { owner, repo } = await getOwnerAndRepo({ dir });
Pushes the specified ref
from the local Git repository to a remote.
Currently, only GitHub app tokens are supported as an auth mechanism.
import { Git } from 'skuba';
await Git.push({
auth: { type: 'gitHubApp' },
dir,
ref: 'commit-id',
remoteRef: 'branch-name',
});
Resets the specified branch in the local Git repository to a particular commit.
import { Git } from 'skuba';
await Git.reset({
dir,
branch: 'main',
commitId: 'abcd1234',
hard: true,
});