@@ -192,32 +192,41 @@ const getGitMetaData = () => {
192192 if ( ! info . author && exports . findGitConfig ( process . cwd ( ) ) ) {
193193 /* commit objects are packed */
194194 gitLastCommit . getLastCommit ( async ( err , commit ) => {
195- info [ "author" ] = info [ "author" ] || `${ commit [ "author" ] [ "name" ] . replace ( / [ “ ] + / g, '' ) } <${ commit [ "author" ] [ "email" ] . replace ( / [ “ ] + / g, '' ) } >` ;
196- info [ "authorDate" ] = info [ "authorDate" ] || commit [ "authoredOn" ] ;
197- info [ "committer" ] = info [ "committer" ] || `${ commit [ "committer" ] [ "name" ] . replace ( / [ “ ] + / g, '' ) } <${ commit [ "committer" ] [ "email" ] . replace ( / [ “ ] + / g, '' ) } >` ;
198- info [ "committerDate" ] = info [ "committerDate" ] || commit [ "committedOn" ]
199- info [ "commitMessage" ] = info [ "commitMessage" ] || commit [ "subject" ] ;
200-
201- const { remote } = await pGitconfig ( info . commonGitDir ) ;
202- const remotes = Object . keys ( remote ) . map ( remoteName => ( { name : remoteName , url : remote [ remoteName ] [ 'url' ] } ) ) ;
203- resolve ( {
204- "name" : "git" ,
205- "sha" : info [ "sha" ] ,
206- "short_sha" : info [ "abbreviatedSha" ] ,
207- "branch" : info [ "branch" ] ,
208- "tag" : info [ "tag" ] ,
209- "committer" : info [ "committer" ] ,
210- "committer_date" : info [ "committerDate" ] ,
211- "author" : info [ "author" ] ,
212- "author_date" : info [ "authorDate" ] ,
213- "commit_message" : info [ "commitMessage" ] ,
214- "root" : info [ "root" ] ,
215- "common_git_dir" : info [ "commonGitDir" ] ,
216- "worktree_git_dir" : info [ "worktreeGitDir" ] ,
217- "last_tag" : info [ "lastTag" ] ,
218- "commits_since_last_tag" : info [ "commitsSinceLastTag" ] ,
219- "remotes" : remotes
220- } ) ;
195+ if ( err ) {
196+ exports . debug ( `Exception in populating Git Metadata with error : ${ err } ` , true , err ) ;
197+ return resolve ( { } ) ;
198+ }
199+ try {
200+ info [ "author" ] = info [ "author" ] || `${ commit [ "author" ] [ "name" ] . replace ( / [ “ ] + / g, '' ) } <${ commit [ "author" ] [ "email" ] . replace ( / [ “ ] + / g, '' ) } >` ;
201+ info [ "authorDate" ] = info [ "authorDate" ] || commit [ "authoredOn" ] ;
202+ info [ "committer" ] = info [ "committer" ] || `${ commit [ "committer" ] [ "name" ] . replace ( / [ “ ] + / g, '' ) } <${ commit [ "committer" ] [ "email" ] . replace ( / [ “ ] + / g, '' ) } >` ;
203+ info [ "committerDate" ] = info [ "committerDate" ] || commit [ "committedOn" ] ;
204+ info [ "commitMessage" ] = info [ "commitMessage" ] || commit [ "subject" ] ;
205+
206+ const { remote } = await pGitconfig ( info . commonGitDir ) ;
207+ const remotes = Object . keys ( remote ) . map ( remoteName => ( { name : remoteName , url : remote [ remoteName ] [ 'url' ] } ) ) ;
208+ resolve ( {
209+ "name" : "git" ,
210+ "sha" : info [ "sha" ] ,
211+ "short_sha" : info [ "abbreviatedSha" ] ,
212+ "branch" : info [ "branch" ] ,
213+ "tag" : info [ "tag" ] ,
214+ "committer" : info [ "committer" ] ,
215+ "committer_date" : info [ "committerDate" ] ,
216+ "author" : info [ "author" ] ,
217+ "author_date" : info [ "authorDate" ] ,
218+ "commit_message" : info [ "commitMessage" ] ,
219+ "root" : info [ "root" ] ,
220+ "common_git_dir" : info [ "commonGitDir" ] ,
221+ "worktree_git_dir" : info [ "worktreeGitDir" ] ,
222+ "last_tag" : info [ "lastTag" ] ,
223+ "commits_since_last_tag" : info [ "commitsSinceLastTag" ] ,
224+ "remotes" : remotes
225+ } ) ;
226+ } catch ( e ) {
227+ exports . debug ( `Exception in populating Git Metadata with error : ${ e } ` , true , e ) ;
228+ return resolve ( { } ) ;
229+ }
221230 } , { dst : exports . findGitConfig ( process . cwd ( ) ) } ) ;
222231 } else {
223232 const { remote } = await pGitconfig ( info . commonGitDir ) ;
0 commit comments