Changeset 05535bbaab81…
Parent ac2d3e2a6f47…
by Benjamin Pollack <benjamin@fogcreek.com>
Changes to 2 files · Browse files at 05535bbaab81 Showing diff from parent ac2d3e2a6f47 Diff from another changeset...
@@ -72,7 +72,9 @@
func (k *KilnClient) DeleteCredentials() (err error) {
creds, err := loadCredentials()
- if err != nil { return }
+ if err != nil {
+ return
+ }
if user, ok := creds[k.credentials.User]; ok {
delete(user, k.credentials.KilnUrl)
}
@@ -127,7 +129,7 @@ if strings.HasPrefix(commit, "fatal:") {
err = fmt.Errorf("commit couldn't be resolved (try \"git fetch\")\n")
} else {
- browse(k.repoRoute(repo, "History/" + commit))
+ browse(k.repoRoute(repo, "History/"+commit))
}
}
return
@@ -136,28 +138,36 @@// Browse a file in Kiln
func (k *KilnClient) BrowseFile(repo string, file string) error {
path, err := repoRelativePath(file)
- if err != nil { return err }
+ if err != nil {
+ return err
+ }
return browse(k.repoRoute(repo, fmt.Sprintf("Files%v", path)))
}
// Browse an annotated file in Kiln
func (k *KilnClient) BrowseAnnotatedFile(repo string, file string) error {
path, err := repoRelativePath(file)
- if err != nil { return err }
+ if err != nil {
+ return err
+ }
return browse(k.repoRoute(repo, fmt.Sprintf("Files%v?view=annotate", path)))
}
// Browse a file in Kiln
func (k *KilnClient) BrowseFileHistory(repo string, file string) error {
path, err := repoRelativePath(file)
- if err != nil { return err }
+ if err != nil {
+ return err
+ }
return browse(k.repoRoute(repo, fmt.Sprintf("FileHistory%v", path)))
}
// Find the root of the Git repo
func GitRoot() (path string, err error) {
out, err := exec.Command("git", "rev-parse", "--show-toplevel").Output()
- if err != nil { return }
+ if err != nil {
+ return
+ }
path = strings.TrimSpace(string(out))
if strings.HasPrefix(path, "fatal:") {
err = fmt.Errorf("unable to find root: %v", path)
@@ -182,9 +192,13 @@// Change a relative or absolute path into a path relative to the repository root
func repoRelativePath(path string) (string, error) {
root, err := GitRoot()
- if err != nil { return "", err }
+ if err != nil {
+ return "", err
+ }
absPath, err := filepath.Abs(path)
- if err != nil { return "", err }
+ if err != nil {
+ return "", err
+ }
absPath = filepath.ToSlash(absPath)
return strings.TrimPrefix(absPath, root), nil
}
|
@@ -54,7 +54,9 @@ base, err = url.Parse(s)
if err != nil || (base.Scheme != "http" && base.Scheme != "https") {
out, err := exec.Command("git", "config", "kiln.url").Output()
- if err == nil { base, err = url.Parse(strings.TrimSpace(string(out))) }
+ if err == nil {
+ base, err = url.Parse(strings.TrimSpace(string(out)))
+ }
}
if err != nil || (base.Scheme != "http" && base.Scheme != "https") {
err = fmt.Errorf("must either have an HTTP remote or kiln.url specified in config")
@@ -63,7 +65,7 @@
components := strings.Split(base.Path, "/")
l := len(components)
- components[l - 1] = strings.TrimSuffix(components[l-1], ".git")
+ components[l-1] = strings.TrimSuffix(components[l-1], ".git")
path = strings.Join(components[l-3:l], "/")
if strings.HasSuffix(base.Host, ".kilnhg.com") {
|
Loading...