You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The func detectRemoteFromInfoCommand(infoOut string) (string, error) returns a remote with a trailing "cariagge return".
If this remote is used the commands issued to svn will always respond with an error.
My solution ..
func detectRemoteFromInfoCommand(infoOut string) (string, error) {
sBytes := []byte(infoOut)
urlIndex := strings.Index(infoOut, "URL: ")
if urlIndex == -1 {
return "", fmt.Errorf("Remote not specified in svn info")
}
urlEndIndex := strings.Index(string(sBytes[urlIndex:]), "\n")
if urlEndIndex == -1 {
urlEndIndex = strings.Index(string(sBytes[urlIndex:]), "\r")
if urlEndIndex == -1 {
return "", fmt.Errorf("Unable to parse remote URL for svn info")
}
}
// bugfix : there is a carriage return at the end we need to remove from the string
// original ..
// return string(sBytes[(urlIndex + 5):(urlIndex + urlEndIndex)]), nil
return string(sBytes[(urlIndex + 5):(urlIndex + urlEndIndex) - 1]), nil
}
The text was updated successfully, but these errors were encountered:
The current code works only on Unix (\n only) and MacOS (\r only).
Windows has both \r\n at the end of lines.
While your change fixes the problem on windows, it breaks the module on Unix.
My suggestion would be to add this just before the existing return at line 384 in svn.go:
if infoOut[urlIndex+urlEndIndex-1:urlIndex+urlEndIndex]=="\r" {
urlEndIndex--
}
i.e. "If the last character on a line is a carriage return then omit it".
This should not break Unix (character before \n will not be \r)
This should not break MacOS (character before \r will not be \r)
This should fix windows (character before \n will be \r and new code will omit it)
What worries me is how many other places in the code are parsing output from svn commands and trying to strip off the newline characters.
If there are others then each one will need to be individually fixed in some similar fashion.
In this case it would probably be better to create some sort of RunSvnCommandGetOutputAsLines(cmd string, arg ...string) ([]string,error) and have every instance of exec.Command(...).GetCombinedOutput() use that instead...
The func detectRemoteFromInfoCommand(infoOut string) (string, error) returns a remote with a trailing "cariagge return".
If this remote is used the commands issued to svn will always respond with an error.
My solution ..
func detectRemoteFromInfoCommand(infoOut string) (string, error) {
sBytes := []byte(infoOut)
urlIndex := strings.Index(infoOut, "URL: ")
if urlIndex == -1 {
return "", fmt.Errorf("Remote not specified in svn info")
}
urlEndIndex := strings.Index(string(sBytes[urlIndex:]), "\n")
if urlEndIndex == -1 {
urlEndIndex = strings.Index(string(sBytes[urlIndex:]), "\r")
if urlEndIndex == -1 {
return "", fmt.Errorf("Unable to parse remote URL for svn info")
}
}
}
The text was updated successfully, but these errors were encountered: