@@ -4,6 +4,7 @@ import * as ci from "env-ci";
44import { gitToJs } from "git-parse" ;
55import * as git from "git-rev-sync" ;
66import { pickBy , identity } from "lodash" ;
7+ import Command from "@oclif/command" ;
78
89const findGitRoot = ( start ?: string | string [ ] ) : string | void => {
910 start = start || process . cwd ( ) ;
@@ -34,22 +35,22 @@ export interface GitContext {
3435 branch ?: string ;
3536}
3637
37- export const gitInfo = async ( ) : Promise < GitContext | undefined > => {
38+ export const gitInfo = async (
39+ log : Command [ "log" ]
40+ ) : Promise < GitContext | undefined > => {
3841 // Occasionally `branch` will be undefined depending on the environment, so
3942 // we need to fallback on `prBranch`. However in some cases, we are not able
4043 // to get to the branch at all. For more information, see
4144 // https://github.com/pvdlg/env-ci#caveats
42- //
43- // slug is formatted as follows: ${organization}/${repository name}
44- const { isCi, commit, branch : ciBranch , slug, root, prBranch } = ci ( ) ;
45+ const { commit, branch : ciBranch , root, prBranch } = ci ( ) ;
4546 const gitLoc = root ? root : findGitRoot ( ) ;
4647
4748 if ( ! commit ) return ;
4849
4950 let committer ;
5051 let branch = ciBranch || prBranch ;
5152 // BUILD_REPOSITORY_ID is for azure pipelines
52- let remoteUrl = slug || process . env . BUILD_REPOSITORY_ID ;
53+ let remoteUrl = process . env . BUILD_REPOSITORY_ID ;
5354 let message ;
5455
5556 // In order to use git-parse and git-rev-sync, we must ensure that a git context is
@@ -69,10 +70,12 @@ export const gitInfo = async (): Promise<GitContext | undefined> => {
6970
7071 message = commit . message ;
7172
72- if ( ! isCi ) {
73- try {
74- remoteUrl = git . remoteUrl ( ) ;
75- } catch ( e ) { }
73+ // The remoteUrl call can fail and throw an error
74+ // https://github.com/kurttheviking/git-rev-sync-js#gitremoteurl--string
75+ try {
76+ remoteUrl = git . remoteUrl ( ) ;
77+ } catch ( e ) {
78+ log ( [ "Unable to retrieve remote url, failed with:" , e ] . join ( "\n\n" ) ) ;
7679 }
7780
7881 // The ci and pr branches pulled from the ci's environment can be undefined,
0 commit comments