Handles all Git-related operations for releases
Direct usage for custom workflows
Direct usage for custom workflows
const git = new GitOperations(config); // Check repository state if (!await git.isGitRepository()) { throw new Error("Not in a git repository"); } // Get commits for analysis const commits = await git.getCommitsSinceLastRelease(); console.log(`Found ${commits.length} commits`); // Parse a specific commit const parsed = git.parseConventionalCommit("feat(api): add user auth"); console.log(`Type: ${parsed.type}, Scope: ${parsed.scope}`);
GitOperations(config: NagareConfig)
config: NagareConfig
logger: Logger
commitAndTag(version: string): Promise<void>
Create commit and tag for release
deleteLocalTag(tag: string): Promise<void>
Delete a local tag
deleteRemoteTag(tag: string): Promise<void>
Delete a remote tag
extractPRNumber(message: string): number | null
Extract PR number from a merge commit message Supports various GitHub merge formats
getCommitsInPR(mergeCommit: string): Promise<ConventionalCommit[]>
Get commits that were part of a PR Returns commits between merge base and the second parent of merge commit
getCommitsSinceLastRelease(): Promise<ConventionalCommit[]>
Get commits since last release
getCurrentBranch(): Promise<string>
Get current branch name.
getCurrentCommitHash(): Promise<string>
Get current commit hash (short format).
getGitUser(): Promise<{ name: string; email: string; }>
Get git user configuration.
getLastCommitMessage(): Promise<string>
Get the last commit message
getLastReleaseTag(): Promise<string>
Get the last release tag.
getLocalTags(): Promise<string[]>
Get list of local tags
getMergeCommits(since: string): Promise<Array<{ sha: string; message: string; date: string; }>>
Get merge commits since a specific tag or commit Used for PR detection in changelog generation
hasUncommittedChanges(): Promise<boolean>
Check for uncommitted changes in the working directory.
isGitRepository(): Promise<boolean>
Check if current directory is a git repository.
parseConventionalCommit(gitLogLine: string): ConventionalCommit | null
Parse a git log line into a conventional commit
pushToRemote(): Promise<void>
Push changes and tags to remote
remoteTagExists(tag: string): Promise<boolean>
Check if a remote tag exists
resetToCommit(commitish: string,hard?: boolean,): Promise<void>
Reset to a previous commit (for rollback)
runCommand(cmd: string[]): Promise<string>
Run a git command and return the output