Skip to content

Commit

Permalink
Fix remote urls without .git
Browse files Browse the repository at this point in the history
  • Loading branch information
bjrnt committed Jan 30, 2024
1 parent 8654664 commit f6d0da6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
Binary file modified alfred-project-manager-1.5.0.alfredworkflow
Binary file not shown.
5 changes: 3 additions & 2 deletions repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ func gitOriginAt(path string) (string, error) {

func urlForOrigin(origin string) string {
if strings.HasPrefix(origin, "[email protected]") {
start := strings.Index(origin, ":")
// format: [email protected]:user/repo.git
end := len(origin) - 1
// sometimes the .git can be missing
indexOfLastPeriod := strings.LastIndex(origin, ".")
indexOfLastPeriod := strings.LastIndex(origin[start+1:], ".")
if indexOfLastPeriod != -1 {
end = indexOfLastPeriod
}
repo := origin[strings.Index(origin, ":")+1 : end]
repo := origin[start+1 : end]
url := fmt.Sprintf("https://github.com/%s", repo)
return url
} else if strings.HasPrefix(origin, "http") {
Expand Down
Binary file modified workflow/alfred-project-manager
Binary file not shown.

0 comments on commit f6d0da6

Please sign in to comment.