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

Commit

Permalink
Rename variables as same as GoReleaser default
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Jun 19, 2023
1 parent cead825 commit 70c4678
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
(prepared bash)

> task
task: [build] go build -ldflags "-X main.revision=$(git rev-parse --short HEAD)"
task: [build] go build ..."
task: [test] go test
task: [lint] dprint check
task: [lint] go vet
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ When I want to bump it, I always visit the nixpkgs repository and copy and paste
## Usage

```console
> go install -ldflags "-X main.revision=$(git rev-parse --short HEAD)"
> go install -ldflags "-X main.commit=$(git rev-parse --short HEAD) -X main.date=$(date --iso-8601)"
> cd repository-that-using-nix
> ${GOPATH:-"$HOME/go"}/bin/nix-headbump && git commit -m 'Bump nixpkgs to latest' *.nix
[main 213d1bf] Bump nixpkgs to latest
Expand Down
4 changes: 2 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ tasks:
- task: build
install:
cmds:
- go install -ldflags "-X main.revision=$(git rev-parse --short HEAD)"
- go install -ldflags "-X main.commit=$(git rev-parse HEAD) -X main.date=$(date --iso-8601)"
build:
cmds:
- go build -ldflags "-X main.revision=$(git rev-parse --short HEAD)"
- go build -ldflags "-X main.commit=$(git rev-parse HEAD) -X main.date=$(date --iso-8601)"
test:
cmds:
- go test
Expand Down
13 changes: 8 additions & 5 deletions nix-headbump.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import (
"regexp"
)

const version string = "0.1.0"
var (
version = "dev"
commit = "none"
date = "unknown"

var re = regexp.MustCompile(`(?s)(import\s+\(fetchTarball\s+"https://github.com/NixOS/nixpkgs/archive/)([^"]+?)(\.tar\.gz"\))`)

var revision string
re = regexp.MustCompile(`(?s)(import\s+\(fetchTarball\s+"https://github.com/NixOS/nixpkgs/archive/)([^"]+?)(\.tar\.gz"\))`)
)

func main() {
versionFlag := flag.Bool("version", false, "print the version of this program")
Expand All @@ -25,7 +27,8 @@ func main() {
flag.Parse()

if *versionFlag {
fmt.Printf("%s\n", version+"("+revision+")")
revision := commit[:7]
fmt.Printf("%s\n", "nix-headbump"+" "+version+" "+"("+revision+") # "+date)
return
}

Expand Down

0 comments on commit 70c4678

Please sign in to comment.