Repository navigation
fix: Var() should trim the trailing newline of git var output - #92
Open
mokshupadhyay wants to merge 1 commit into
Open
mokshupadhyay wants to merge 1 commit into
mokshupadhyay wants to merge 1 commit into
Conversation
…tor() returns a clean editor command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
gitw.Var(name)runsgit var <name>and returned the command output as it is, including the trailing newline.Editor()usesVar("GIT_EDITOR")as its fallback, so it can return an editor value that is just a newline.Real results of
Var("GIT_EDITOR")andEditor()with theGIT_EDITOR,VISUALandEDITORenvironment variables set to empty (soEditor()has to fall back togit var), onmasterand with this change:The fix trims the trailing
\rand\nfrom the output ofgit var.Test:
TestVar_noTrailingNewlineinutil_test.gochecks thatVar("GIT_DEFAULT_BRANCH")(git always prints a name for it) is not empty and has no trailing newline; it fails onmasterand passes now.go test ./...passes in every package,go vet ./...reports nothing and the changed files are gofmt-clean. I did not rungolangci-lint.