Skip to content

Commit 51adf91

Browse files
committed
feat: resolve and store current repo branch
1 parent cd80e5b commit 51adf91

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/services/git.service.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,10 @@ export async function cloneRepo(url: string, targetDir: string) {
1212
export async function pullLatest(targetDir: string) {
1313
return await run(`git checkout --force && git pull --depth 1`, targetDir);
1414
}
15+
16+
export async function getCurrentBranch(
17+
targetDir: string = '.'
18+
): Promise<string> {
19+
const { stdout } = await run(`git branch --show-current`, targetDir);
20+
return stdout.trim();
21+
}

lib/tasks/project-info.task.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
isNpmWorkspace,
1515
isPipWorkspace,
1616
} from '../services/project.service';
17+
import { getCurrentBranch } from "../services/git.service";
1718

1819
export const projectInfoTask: ListrTask = {
1920
title: 'Resolve basic project info',
@@ -120,8 +121,11 @@ export const projectInfoTask: ListrTask = {
120121
new Set([...repos, ...reposNpm, ...reposMaven])
121122
);
122123

124+
const branch = await getCurrentBranch();
125+
123126
ctx.results.info = {
124127
...ctx.results.info,
128+
branch,
125129
repository: repositories[0],
126130
repositories,
127131
} as any;

0 commit comments

Comments
 (0)