@@ -138,13 +138,31 @@ export function activateCoverage(context: ExtensionContext) {
138138 ) ?. uri . path ;
139139
140140 const gitConfig = Uri . file ( `${ pathToWorkspace } /.git/config` ) ;
141- const remote = await workspace . fs
141+ const configLines = workspace . fs
142142 . readFile ( gitConfig )
143143 . then ( ( buf ) => buf . toString ( ) )
144- . then ( ( string ) => string . split ( "\n" ) )
145- . then ( ( lines ) => lines . find ( ( line ) => line . match ( / g i t @ .* : .* \/ .* .g i t $ / ) ) )
146- . then ( ( line ) => line ?. replace ( / .* : / , "" ) . replace ( ".git" , "" ) . split ( "/" ) ) ;
147- if ( ! remote ) return ;
144+ . then ( ( string ) => string . split ( "\n" ) ) ;
145+ // Try https remote auth first
146+ let remote = await configLines
147+ . then ( ( lines ) =>
148+ lines . find ( ( line ) => line . match ( / h t t p s : \/ \/ .* \/ .* \/ .* .g i t $ / ) )
149+ )
150+ . then ( ( line ) =>
151+ line
152+ ?. replace ( / .* h t t p s : \/ \/ [ ^ \/ ] * \/ / , "" )
153+ . replace ( ".git" , "" )
154+ . split ( "/" )
155+ ) ;
156+ if ( ! remote ) {
157+ // if that doesn't work try looking for remotes using ssh auth
158+ remote = await configLines
159+ . then ( ( lines ) => lines . find ( ( line ) => line . match ( / g i t @ .* : .* \/ .* .g i t $ / ) ) )
160+ . then ( ( line ) =>
161+ line ?. replace ( / .* : / , "" ) . replace ( ".git" , "" ) . split ( "/" )
162+ ) ;
163+ }
164+ // Throw so we can see this in Sentry
165+ if ( ! remote ) throw new Error ( "Could not get remote from .git directory" ) ;
148166 const [ owner , repo ] = remote ;
149167
150168 const gitHead = Uri . file ( `${ pathToWorkspace } /.git/HEAD` ) ;
@@ -193,7 +211,8 @@ export function activateCoverage(context: ExtensionContext) {
193211 error = error ;
194212 } ) ;
195213
196- if ( error ) return ;
214+ // Throw so we can get these in Sentry
215+ if ( error ) throw error ;
197216
198217 if ( ! coverage || ! coverage . line_coverage ) {
199218 // No coverage for this file/branch. Fall back to default branch coverage.
0 commit comments