aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/prompt/pwd.go12
-rw-r--r--internal/rtree/index.go9
2 files changed, 10 insertions, 11 deletions
diff --git a/internal/prompt/pwd.go b/internal/prompt/pwd.go
index b549a39..e10da84 100644
--- a/internal/prompt/pwd.go
+++ b/internal/prompt/pwd.go
@@ -9,7 +9,7 @@ import (
"strings"
)
-//Directory contains all data about a directory that the prompt needs.
+// Directory contains all data about a directory that the prompt needs.
type Directory struct {
Path string
DisplayPath string //formatted for display in prompt line
@@ -20,8 +20,7 @@ type Directory struct {
NearestAccessiblePath string
}
-//CurrentDirectory prepares a Directory struct for the current working
-//directory.
+// CurrentDirectory prepares a Directory struct for the current working directory.
func CurrentDirectory() Directory {
cwd, err := os.Getwd()
if err != nil {
@@ -30,7 +29,7 @@ func CurrentDirectory() Directory {
return NewDirectory(cwd)
}
-//NewDirectory prepares a Directory struct for the given path.
+// NewDirectory prepares a Directory struct for the given path.
func NewDirectory(path string) (dir Directory) {
dir.Path = path
dir.DisplayPath = path
@@ -82,7 +81,7 @@ func NewDirectory(path string) (dir Directory) {
return
}
-//This part can benefit from a "return" in the middle, so it's in a separate function.
+// This part can benefit from a "return" in the middle, so it's in a separate function.
func (dir *Directory) stripHomeDirFromDisplay() {
if !strings.HasPrefix(dir.DisplayPath, "/") {
return
@@ -129,8 +128,7 @@ func getDirectoryField(dir Directory, tt *TerminalTitle) string {
//cwd accessible -> highlight path elements inside the repo (if any)
if dir.Repo != nil && dir.Repo.RootPath != dir.Path {
rel, _ := filepath.Rel(dir.Repo.RootPath, dir.Path)
- if strings.HasSuffix(dir.DisplayPath, rel) {
- base := strings.TrimSuffix(dir.DisplayPath, rel)
+ if base, ok := strings.CutSuffix(dir.DisplayPath, rel); ok {
txt = withColor("0;36", base) + withColor("1;36", rel)
}
}
diff --git a/internal/rtree/index.go b/internal/rtree/index.go
index 1432161..549b51c 100644
--- a/internal/rtree/index.go
+++ b/internal/rtree/index.go
@@ -312,12 +312,13 @@ func (i *Index) FindRepo(rawRemoteURL string, allowClone bool) (*Repo, error) {
}
//report the existing remotes, and ask for the name of the new remote
- prompt := "Existing remotes:\n"
+ var prompt strings.Builder
+ prompt.WriteString("Existing remotes:\n")
for remoteName, remote := range target.Remotes {
- prompt += fmt.Sprintf("\t(%s) %s\n", remoteName, strings.Join(remote.CompactURLs(), " "))
+ fmt.Fprintf(&prompt, "\t(%s) %s\n", remoteName, strings.Join(remote.CompactURLs(), " "))
}
- prompt += fmt.Sprintf("Enter remote name for %s:", remoteURL)
- remoteName, err := cli.Interface.ReadLine(prompt)
+ fmt.Fprintf(&prompt, "Enter remote name for %s:", remoteURL)
+ remoteName, err := cli.Interface.ReadLine(prompt.String())
if err != nil {
return nil, err
}