@@ -337,8 +337,8 @@ func determineRemote(ctx context.Context, forkUser string) (string, string, erro
337337 fmt .Fprintf (os .Stderr , "Unable to list git remotes:\n %s\n " , string (out ))
338338 return "" , "" , fmt .Errorf ("unable to determine forked remote: %w" , err )
339339 }
340- lines := strings .Split (string (out ), "\n " )
341- for _ , line := range lines {
340+ lines := strings .SplitSeq (string (out ), "\n " )
341+ for line := range lines {
342342 fields := strings .Split (line , "\t " )
343343 name , remote := fields [0 ], fields [1 ]
344344 // only look at pushers
@@ -356,12 +356,12 @@ func determineRemote(ctx context.Context, forkUser string) (string, string, erro
356356 if ! strings .Contains (remote , forkUser ) {
357357 continue
358358 }
359- if strings .
HasPrefix (
remote ,
"[email protected] :" ) {
360- forkUser = strings . TrimPrefix ( remote , "[email protected] :" ) 361- } else if strings .HasPrefix (remote , "https://github.com/" ) {
362- forkUser = strings . TrimPrefix ( remote , "https://github.com/" )
363- } else if strings .HasPrefix (remote , "https://www.github.com/" ) {
364- forkUser = strings . TrimPrefix ( remote , "https://www.github.com/" )
359+ if after , ok := strings .
CutPrefix (
remote ,
"[email protected] :" )
; ok {
360+ forkUser = after
361+ } else if after , ok := strings .CutPrefix (remote , "https://github.com/" ); ok {
362+ forkUser = after
363+ } else if after , ok := strings .CutPrefix (remote , "https://www.github.com/" ); ok {
364+ forkUser = after
365365 } else if forkUser == "" {
366366 return "" , "" , fmt .Errorf ("unable to extract forkUser from remote %s: %s" , name , remote )
367367 }
0 commit comments