Merge branch 'master' of github.com:Netflix-Skunkworks/go-jira

This commit is contained in:
Cory Bennett
2016-06-29 01:40:21 +01:00
2 changed files with 45 additions and 24 deletions
+8 -9
View File
@@ -17,14 +17,14 @@ NAME=jira
OS=$(shell uname -s) OS=$(shell uname -s)
ifeq ($(filter CYGWIN%,$(OS)),$(OS)) ifeq ($(filter CYGWIN%,$(OS)),$(OS))
export CWD=$(shell cygpath -wa .) export CWD=$(shell cygpath -wa .)
export SEP=\\ export SEP=\\
export CYGWIN=winsymlinks:native export CYGWIN=winsymlinks:native
BIN ?= $(GOBIN)$(SEP)$(NAME).exe BIN ?= $(GOBIN)$(SEP)$(NAME).exe
else else
export CWD=$(shell pwd) export CWD=$(shell pwd)
export SEP=/ export SEP=/
BIN ?= $(GOBIN)$(SEP)$(NAME) BIN ?= $(GOBIN)$(SEP)$(NAME)
endif endif
export GOPATH=$(CWD) export GOPATH=$(CWD)
@@ -33,7 +33,6 @@ DIST=$(CWD)$(SEP)dist
GOBIN ?= $(CWD) GOBIN ?= $(CWD)
CURVER ?= $(shell [ -d .git ] && git describe --abbrev=0 --tags || grep ^\#\# CHANGELOG.md | awk '{print $$2; exit}') CURVER ?= $(shell [ -d .git ] && git describe --abbrev=0 --tags || grep ^\#\# CHANGELOG.md | awk '{print $$2; exit}')
LDFLAGS:=-X jira.VERSION=$(patsubst v%,%,$(CURVER)) -w LDFLAGS:=-X jira.VERSION=$(patsubst v%,%,$(CURVER)) -w
@@ -55,7 +54,7 @@ src/%:
cross-setup: cross-setup:
for p in $(PLATFORMS); do \ for p in $(PLATFORMS); do \
echo "Building for $$p"; \ echo Building for $$p"; \
cd $(GOROOT)/src && sudo GOROOT_BOOTSTRAP=$(GOROOT) GOOS=$${p/-*/} GOARCH=$${p/*-/} bash ./make.bash --no-clean; \ cd $(GOROOT)/src && sudo GOROOT_BOOTSTRAP=$(GOROOT) GOOS=$${p/-*/} GOARCH=$${p/*-/} bash ./make.bash --no-clean; \
done done
+36 -14
View File
@@ -6,6 +6,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"path/filepath"
"github.com/mgutz/ansi" "github.com/mgutz/ansi"
"gopkg.in/coryb/yaml.v2" "gopkg.in/coryb/yaml.v2"
"io" "io"
@@ -13,36 +14,57 @@ import (
"net/http" "net/http"
"os" "os"
"strings" "strings"
"runtime"
"text/template" "text/template"
"time" "time"
) )
func homedir() string {
log.Errorf("GOOS: %s", runtime.GOOS)
if runtime.GOOS == "windows" {
return os.Getenv("USERPROFILE")
}
return os.Getenv("HOME")
}
func FindParentPaths(fileName string) []string { func FindParentPaths(fileName string) []string {
cwd, _ := os.Getwd() cwd, _ := os.Getwd()
paths := make([]string, 0) paths := make([]string, 0)
// special case if homedir is not in current path then check there anyway // special case if homedir is not in current path then check there anyway
homedir := os.Getenv("HOME") homedir := homedir()
if !strings.HasPrefix(cwd, homedir) { if !filepath.HasPrefix(cwd, homedir) {
file := fmt.Sprintf("%s/%s", homedir, fileName) path := filepath.Join(homedir, fileName)
if _, err := os.Stat(file); err == nil { if _, err := os.Stat(path); err == nil {
paths = append(paths, file) paths = append(paths, path)
} }
} }
var dir string
for _, part := range strings.Split(cwd, string(os.PathSeparator)) { path := filepath.Join(cwd, fileName)
if dir == "/" { if _, err := os.Stat(path); err == nil {
dir = fmt.Sprintf("/%s", part) paths = append(paths, path)
} else { }
dir = fmt.Sprintf("%s/%s", dir, part) for true {
cwd = filepath.Dir(cwd)
path := filepath.Join(cwd, fileName)
if _, err := os.Stat(path); err == nil {
paths = append(paths, path)
} }
file := fmt.Sprintf("%s/%s", dir, fileName) if cwd[len(cwd)-1]== filepath.Separator {
if _, err := os.Stat(file); err == nil { break
paths = append(paths, file)
} }
} }
// for _, part := range strings.Split(cwd, string(os.PathSeparator)) {
// if dir == "/" {
// dir = fmt.Sprintf("/%s", part)
// } else {
// dir = fmt.Sprintf("%s/%s", dir, part)
// }
// file := fmt.Sprintf("%s/%s", dir, fileName)
// }
log.Errorf("PATHS: %#v", paths)
return paths return paths
} }