Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Commit

Permalink
Implement jump flag to check the git ref in nixpkgs repository (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Jul 28, 2023
1 parent 8de9a0d commit 103f5f4
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions cmd/nixpkgs-url/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ $ nixpkgs-url -version`
lastFlag := detectCmd.Bool("last", false, "print git head ref without bumping")
targetFlag := detectCmd.Bool("target", false, "print which file will be bumped")

// Do not call as xdg-open for WSL2, URL will be displayed as a clickable in newer terminals, it is enough
// https://github.com/microsoft/WSL/issues/8892
jumpFlag := detectCmd.Bool("jump", false, "print reasonable URL for the ref")

flag.Usage = func() {
// https://github.com/golang/go/issues/57059#issuecomment-1336036866
fmt.Printf("%s", usage+"\n\n")
Expand Down Expand Up @@ -82,15 +86,25 @@ $ nixpkgs-url -version`
if err != nil {
log.Fatalf("Getting the current version has been failed: %s", err.Error())
}
fmt.Println(current)

if *jumpFlag {
fmt.Println("https://github.com/NixOS/nixpkgs/commit/" + current)
} else {
fmt.Println(current)
}

return
}
last, err := nixurl.GetLastVersion()
if err != nil {
log.Fatalf("Getting the last version has been failed: %s", err.Error())
}
if *lastFlag {
fmt.Println(last)
if *jumpFlag {
fmt.Println("https://github.com/NixOS/nixpkgs/commit/" + last)
} else {
fmt.Println(last)
}
return
}

Expand Down

0 comments on commit 103f5f4

Please sign in to comment.