Changeset 543065b40c93…
Parent 87c6e5aade72…
by Benjamin Pollack <benjamin@fogcreek.com>
Changes to one file · Browse files at 543065b40c93 Showing diff from parent 87c6e5aade72 Diff from another changeset...
@@ -108,6 +108,19 @@ return nil
}
+// Resolve a Git SHA
+func (k *KilnClient) ResolveSHA(commit string) (string, error) {
+ if out, err := exec.Command("git", "rev-parse", commit).CombinedOutput(); err == nil {
+ commit := strings.TrimSpace(string(out))
+ if strings.HasPrefix(commit, "fatal:") {
+ return "", fmt.Errorf("commit couldn't be resolved (try \"git fetch\" first)")
+ } else {
+ return commit, nil
+ }
+ }
+ return "", fmt.Errorf("commit couldn't be resolved (try \"git fetch\" first)")
+}
+
// Browses the history tab of the repository
func (k *KilnClient) BrowseHistory(repo string) error {
return browse(k.repoRoute(repo, ""))
@@ -125,16 +138,8 @@
// Browse a commit, expanding out to the full SHA beforehand
func (k *KilnClient) BrowseCommit(repo string, commit string) (err error) {
- var out []byte
- if out, err = exec.Command("git", "rev-parse", commit).CombinedOutput(); err == nil {
- commit = strings.TrimSpace(string(out))
- if strings.HasPrefix(commit, "fatal:") {
- err = fmt.Errorf("commit couldn't be resolved (try \"git fetch\" first)")
- } else {
- browse(k.repoRoute(repo, "History/"+commit))
- }
- } else {
- err = fmt.Errorf("commit couldn't be resolved (try \"git fetch\" first)")
+ if commit, err = k.ResolveSHA(commit); err == nil {
+ err = browse(k.repoRoute(repo, "History/"+commit))
}
return
}
|
Loading...