Skip to content
This repository was archived by the owner on Jun 7, 2024. It is now read-only.

Commit f28d9df

Browse files
authored
[convHelper] optz logic
1 parent 66de7d6 commit f28d9df

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/fgit.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,20 @@ func convertHelper(oldPrefixValue, newPrefixValue string) bool {
107107
isReplaceDo := false
108108
sb := new(bytes.Buffer)
109109
iniArray := strings.Split(gitConfig, "\n")
110+
111+
iniNewStr := ""
112+
110113
for i := range iniArray {
111-
iniArray[i] = strings.Replace(iniArray[i], oldPrefixValue, newPrefixValue, 1)
112-
isReplaceDo = true
114+
if strings.Trim(iniArray[i], "") == "" {
115+
// drop useless lines
116+
// sb.WriteString(iniArray[i] + "\n")
117+
continue
118+
}
119+
iniNewStr = strings.Replace(iniArray[i], oldPrefixValue, newPrefixValue, 1)
120+
if iniArray[i] != iniNewStr {
121+
iniArray[i] = iniNewStr
122+
isReplaceDo = true
123+
}
113124
sb.WriteString(iniArray[i] + "\n")
114125
}
115126
fi.Write(sb.Bytes())

0 commit comments

Comments
 (0)