@@ -69,7 +69,7 @@ const postProcessBranches =
69
69
. map ( ( branch ) => {
70
70
let name = branch . trim ( ) ;
71
71
const parts = branch . match ( / \S + / g) ;
72
- if ( parts . length > 1 ) {
72
+ if ( parts && parts . length > 1 ) {
73
73
if ( parts [ 0 ] === "*" ) {
74
74
// We are in a detached HEAD state
75
75
if ( branch . includes ( "HEAD detached" ) ) {
@@ -108,6 +108,7 @@ const postProcessBranches =
108
108
} ;
109
109
} )
110
110
. filter ( ( suggestion ) => {
111
+ if ( ! suggestion ) return false ;
111
112
if ( seen . has ( suggestion . name ) ) return false ;
112
113
seen . add ( suggestion . name ) ;
113
114
return true ;
@@ -259,7 +260,7 @@ export const gitGenerators: Record<string, Fig.Generator> = {
259
260
custom : async ( tokens , executeShellCommand ) => {
260
261
const pp = postProcessBranches ( { insertWithoutRemotes : true } ) ;
261
262
if ( tokens . includes ( "-r" ) ) {
262
- return pp (
263
+ return pp ?. (
263
264
(
264
265
await executeShellCommand ( {
265
266
command : "git" ,
@@ -274,7 +275,7 @@ export const gitGenerators: Record<string, Fig.Generator> = {
274
275
tokens
275
276
) ;
276
277
} else {
277
- return pp (
278
+ return pp ?. (
278
279
(
279
280
await executeShellCommand ( {
280
281
command : "git" ,
@@ -295,14 +296,16 @@ export const gitGenerators: Record<string, Fig.Generator> = {
295
296
remotes : {
296
297
script : [ "git" , "--no-optional-locks" , "remote" , "-v" ] ,
297
298
postProcess : function ( out ) {
298
- const remoteURLs = out . split ( "\n" ) . reduce ( ( dict , line ) => {
299
- const pair = line . split ( "\t" ) ;
300
- const remote = pair [ 0 ] ;
301
- const url = pair [ 1 ] . split ( " " ) [ 0 ] ;
299
+ const remoteURLs = out
300
+ . split ( "\n" )
301
+ . reduce < Record < string , string > > ( ( dict , line ) => {
302
+ const pair = line . split ( "\t" ) ;
303
+ const remote = pair [ 0 ] ;
304
+ const url = pair [ 1 ] . split ( " " ) [ 0 ] ;
302
305
303
- dict [ remote ] = url ;
304
- return dict ;
305
- } , { } ) ;
306
+ dict [ remote ] = url ;
307
+ return dict ;
308
+ } , { } ) ;
306
309
307
310
return Object . keys ( remoteURLs ) . map ( ( remote ) => {
308
311
const url = remoteURLs [ remote ] ;
0 commit comments