Skip to content

Commit

Permalink
Develop (#21)
Browse files Browse the repository at this point in the history
* add search feature to branch subcommand

* bump version

* add optional arg to "make install" for setting gopath
  • Loading branch information
isacikgoz authored Feb 6, 2019
1 parent 680b327 commit b01a50a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GITIN_BUILD_FLAGS=--tags static -ldflags "$(GITIN_LDFLAGS)"
GITIN_STATIC_BUILD_FLAGS=--tags static -ldflags "$(GITIN_LDFLAGS) $(GITIN_STATIC_LDFLAGS)"

GITIN_DIR:=$(dir $(realpath $(lastword $(MAKEFILE_LIST))))
GOPATH_DIR:=$(shell go env GOPATH)
GOPATH_DIR?=$(shell go env GOPATH | cut -d: -f1)
GOBIN_DIR:=$(GOPATH_DIR)/bin

GIT2GO_VERSION=27
Expand Down
9 changes: 9 additions & 0 deletions cli/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"os/exec"
"strings"

"github.com/isacikgoz/gitin/git"
"github.com/isacikgoz/promptui"
Expand Down Expand Up @@ -60,6 +61,13 @@ func branchPrompt(r *git.Repository, opts *PromptOptions) error {
fmt.Printf("\x1b[?7l")
// defer restoring line wrap
defer fmt.Printf("\x1b[?7h")
searcher := func(input string, index int) bool {
item := r.Branches[index]
name := strings.Replace(strings.ToLower(item.Name), " ", "", -1)
input = strings.Replace(strings.ToLower(input), " ", "", -1)

return strings.Contains(name, input)
}

var prompt promptui.Select
kset := make(map[rune]promptui.CustomFunc)
Expand Down Expand Up @@ -90,6 +98,7 @@ func branchPrompt(r *git.Repository, opts *PromptOptions) error {
Label: "Branches",
Items: r.Branches,
HideHelp: opts.HideHelp,
Searcher: searcher,
Size: opts.Size,
Templates: branchTemplate(),
CustomFuncs: kset,
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var (

func main() {

pin.Version("gitin version 0.1.0")
pin.Version("gitin version 0.1.1")
pin.CommandLine.HelpFlag.Short('h')
pin.CommandLine.VersionFlag.Short('v')
pin.Parse()
Expand Down

0 comments on commit b01a50a

Please sign in to comment.