Skip to content
Myr

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

4 files+25 added−15 removed

modified:src/core.go+6 added-2 removed
41 unmodified lines
42Matcher -> EvtHeader -> Terminal (update header)43*/4445// Run starts fzf46func Run(opts *Options) {46func Run(opts *Options, revision string) {47 sort := opts.Sort > 048 sortCriteria = opts.Criteria4950 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 }5859 // Event channel
233 unmodified lines
modified:install+1 added-1 removed
70 unmodified lines
7172check_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" ]; then
265 unmodified lines
modified:main.go+3 added-1 removed
1package main23import "github.com/junegunn/fzf/src"45var revision string67func main() {6 fzf.Run(fzf.ParseOptions())8 fzf.Run(fzf.ParseOptions(), revision)9}
modified:Makefile+15 added-11 removed
7 unmodified lines
8$(error "$$GOOS is not defined.")9endif10endif1112ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))12MAKEFILE := $(realpath $(lastword $(MAKEFILE_LIST)))13ROOT_DIR := $(shell dirname $(MAKEFILE))14GOPATH := $(ROOT_DIR)/gopath15SRC_LINK := $(GOPATH)/src/github.com/junegunn/fzf/src16VENDOR_LINK := $(GOPATH)/src/github.com/junegunn/fzf/vendor17export GOPATH1819GLIDE_YAML := glide.yaml20GLIDE_LOCK := glide.lock19SOURCES := $(wildcard *.go src/*.go src/*/*.go) $(SRC_LINK) $(VENDOR_LINK) $(GLIDE_LOCK)21SOURCES := $(wildcard *.go src/*.go src/*/*.go) $(SRC_LINK) $(VENDOR_LINK) $(GLIDE_LOCK) $(MAKEFILE)2223REVISION := $(shell git log -n 1 --pretty=format:%h -- $(SOURCES))24BUILD_FLAGS := -a -ldflags "-X main.revision=$(REVISION) -w -extldflags=$(LDFLAGS)" -tags "$(TAGS)"2526BINARY32 := fzf-$(GOOS)_38627BINARY64 := fzf-$(GOOS)_amd6428BINARYARM5 := fzf-$(GOOS)_arm529BINARYARM6 := fzf-$(GOOS)_arm6
5 unmodified lines
35RELEASEARM5 := fzf-$(VERSION)-$(GOOS)_arm536RELEASEARM6 := fzf-$(VERSION)-$(GOOS)_arm637RELEASEARM7 := fzf-$(VERSION)-$(GOOS)_arm738RELEASEARM8 := fzf-$(VERSION)-$(GOOS)_arm834export GOPATH3940# https://en.wikipedia.org/wiki/Uname41UNAME_M := $(shell uname -m)42ifeq ($(UNAME_M),x86_64)
20 unmodified lines
63 mkdir -p $@6465ifeq ($(GOOS),windows)66release: 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.exe70else ifeq ($(GOOS),linux)71release: target/$(BINARY32) target/$(BINARY64) target/$(BINARYARM5) target/$(BINARYARM6) target/$(BINARYARM7) target/$(BINARYARM8)72 cd target && cp -f $(BINARY32) fzf && tar -czf $(RELEASE32).tgz fzf
40 unmodified lines
113clean:114 rm -rf target115116target/$(BINARY32): $(SOURCES)113 GOARCH=386 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@117 GOARCH=386 go build $(BUILD_FLAGS) -o $@118119target/$(BINARY64): $(SOURCES)116 GOARCH=amd64 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@120 GOARCH=amd64 go build $(BUILD_FLAGS) -o $@121122# https://github.com/golang/go/wiki/GoArm123target/$(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 $@125126target/$(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 $@128129target/$(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 $@131132target/$(BINARYARM8): $(SOURCES)129 GOARCH=arm64 go build -a -ldflags "-w -extldflags=$(LDFLAGS)" -tags "$(TAGS)" -o $@133 GOARCH=arm64 go build $(BUILD_FLAGS) -o $@134135bin/fzf: target/$(BINARY) | bin136 cp -f target/$(BINARY) bin/fzf137
1 unmodified line