Add git revision to --version output
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Junegunn Choi · committed by Junegunn Choi · parent 8bbf933 · Browse files · 4 files·+25 added−15 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+25 added−15 removed
- other:+25 added−15 removed
Provenance
- Commit
83e9af6- Tree
ac014e1- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
8bbf933
4 files changed+25 added−15 removed
modified:src/core.go+6 added-2 removed
41 unmodified lines42 Matcher -> EvtHeader -> Terminal (update header)43 */44 45 // Run starts fzf46-func Run(opts *Options) {46+func Run(opts *Options, revision string) {47 sort := opts.Sort > 048 sortCriteria = opts.Criteria49 50 if opts.Version {51+ if len(revision) > 0 {52+ fmt.Printf("%s (%s)\n", version, revision)53+ } else {51- fmt.Println(version)54+ fmt.Println(version)55+ }56 os.Exit(exitOk)57 }58 59 // Event channel233 unmodified linesmodified:install+1 added-1 removed
70 unmodified lines71 72 check_binary() {73 echo -n " - Checking fzf executable ... "74 local output75- output=$("$fzf_base"/bin/fzf --version 2>&1)75+ output=$("$fzf_base"/bin/fzf --version 2>&1 | awk '{print $1}')76 if [ $? -ne 0 ]; then77 echo "Error: $output"78 binary_error="Invalid binary"79 elif [ "$version" != "$output" ]; then265 unmodified linesmodified:main.go+3 added-1 removed
1 package main2 3 import "github.com/junegunn/fzf/src"4 5+var revision string6+7 func main() {6- fzf.Run(fzf.ParseOptions())8+ fzf.Run(fzf.ParseOptions(), revision)9 }modified:Makefile+15 added-11 removed
7 unmodified lines8 $(error "$$GOOS is not defined.")9 endif10 endif11 12-ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))12+MAKEFILE := $(realpath $(lastword $(MAKEFILE_LIST)))13+ROOT_DIR := $(shell dirname $(MAKEFILE))14 GOPATH := $(ROOT_DIR)/gopath15 SRC_LINK := $(GOPATH)/src/github.com/junegunn/fzf/src16 VENDOR_LINK := $(GOPATH)/src/github.com/junegunn/fzf/vendor17+export GOPATH18 19 GLIDE_YAML := glide.yaml20 GLIDE_LOCK := glide.lock19-SOURCES := $(wildcard *.go src/*.go src/*/*.go) $(SRC_LINK) $(VENDOR_LINK) $(GLIDE_LOCK)21+SOURCES := $(wildcard *.go src/*.go src/*/*.go) $(SRC_LINK) $(VENDOR_LINK) $(GLIDE_LOCK) $(MAKEFILE)22 23+REVISION := $(shell git log -n 1 --pretty=format:%h -- $(SOURCES))24+BUILD_FLAGS := -a -ldflags "-X main.revision=$(REVISION) -w -extldflags=$(LDFLAGS)" -tags "$(TAGS)"25+26 BINARY32 := fzf-$(GOOS)_38627 BINARY64 := fzf-$(GOOS)_amd6428 BINARYARM5 := fzf-$(GOOS)_arm529 BINARYARM6 := fzf-$(GOOS)_arm65 unmodified lines35 RELEASEARM5 := fzf-$(VERSION)-$(GOOS)_arm536 RELEASEARM6 := fzf-$(VERSION)-$(GOOS)_arm637 RELEASEARM7 := fzf-$(VERSION)-$(GOOS)_arm738 RELEASEARM8 := fzf-$(VERSION)-$(GOOS)_arm834-export GOPATH39 40 # https://en.wikipedia.org/wiki/Uname41 UNAME_M := $(shell uname -m)42 ifeq ($(UNAME_M),x86_64)20 unmodified lines63 mkdir -p $@64 65 ifeq ($(GOOS),windows)66 release: target/$(BINARY32) target/$(BINARY64)63- cd target && cp -f $(BINARY32) fzf.exe && zip $(RELEASE32).zip bin/fzf.exe64- cd target && cp -f $(BINARY64) fzf.exe && zip $(RELEASE64).zip bin/fzf.exe67+ cd target && cp -f $(BINARY32) fzf.exe && zip $(RELEASE32).zip fzf.exe68+ cd target && cp -f $(BINARY64) fzf.exe && zip $(RELEASE64).zip fzf.exe69 cd target && rm -f fzf.exe70 else ifeq ($(GOOS),linux)71 release: target/$(BINARY32) target/$(BINARY64) target/$(BINARYARM5) target/$(BINARYARM6) target/$(BINARYARM7) target/$(BINARYARM8)72 cd target && cp -f $(BINARY32) fzf && tar -czf $(RELEASE32).tgz fzf40 unmodified lines113 clean:114 rm -rf target115 116 target/$(BINARY32): $(SOURCES)113- GOARCH=386 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@117+ GOARCH=386 go build $(BUILD_FLAGS) -o $@118 119 target/$(BINARY64): $(SOURCES)116- GOARCH=amd64 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@120+ GOARCH=amd64 go build $(BUILD_FLAGS) -o $@121 122 # https://github.com/golang/go/wiki/GoArm123 target/$(BINARYARM5): $(SOURCES)120- GOARCH=arm GOARM=5 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@124+ GOARCH=arm GOARM=5 go build $(BUILD_FLAGS) -o $@125 126 target/$(BINARYARM6): $(SOURCES)123- GOARCH=arm GOARM=6 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@127+ GOARCH=arm GOARM=6 go build $(BUILD_FLAGS) -o $@128 129 target/$(BINARYARM7): $(SOURCES)126- GOARCH=arm GOARM=7 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@130+ GOARCH=arm GOARM=7 go build $(BUILD_FLAGS) -o $@131 132 target/$(BINARYARM8): $(SOURCES)129- GOARCH=arm64 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@133+ GOARCH=arm64 go build $(BUILD_FLAGS) -o $@134 135 bin/fzf: target/$(BINARY) | bin136 cp -f target/$(BINARY) bin/fzf137 1 unmodified line