Skip to content

Commit 3cd0931

Browse files
cexbrayatmgechev
authored andcommitted
fix(@angular/cli): correct git branch in ng version
When testing a local CLI build with `npm link @angular/cli`, if you run `ng version`, you currently see: Angular CLI: local (v8.1.0-beta.2+24.3bb67d8.with-local-changes, branch: version) if the Git branch is `fix/version`. Whit this PR, `ng version` now displays the proper Git branch name: Angular CLI: local (v8.1.0-beta.2+24.3bb67d8.with-local-changes, branch: fix/version)
1 parent 0ed8de1 commit 3cd0931

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/angular/cli/commands/version-impl.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,12 @@ export class VersionCommand extends Command<VersionCommandSchema> {
8484
if (!__dirname.match(/node_modules/)) {
8585
let gitBranch = '??';
8686
try {
87-
const gitRefName = '' + child_process.execSync('git symbolic-ref HEAD', {cwd: __dirname});
88-
gitBranch = path.basename(gitRefName.replace('\n', ''));
87+
const gitRefName = child_process.execSync('git rev-parse --abbrev-ref HEAD', {
88+
cwd: __dirname,
89+
encoding: 'utf8',
90+
stdio: 'pipe',
91+
});
92+
gitBranch = gitRefName.replace('\n', '');
8993
} catch {
9094
}
9195

0 commit comments

Comments
 (0)