-
Notifications
You must be signed in to change notification settings - Fork 533
current_branch
contains color escape codes
#427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Sad, that there was no reaction at all. Do you need further support here? |
Sorry, Marcel, we are working to get more attention on this project starting with making the stale[bot] much less aggressive. |
Shouldn't we ALWAYS call I think the answer is yes. If so, then we should look for a way to turn it off for all commands. https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_colors_in_git |
Marcel, what do you think of this? My hypothesis is that adding https://github.com/ruby-git/ruby-git/blob/master/lib/git/lib.rb#L945-L947 will turn off color for all commands. If I understand it correctly, this will override the color setting for all commands that support it no matter what is in the user configuration. https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_code_color_ui_code If you agree, will you test this hypothesis and, if it works, submit a update with that implementation? Please include at least one test that asserts that this option is added to commands. |
@jcouball, sadly this is not working with the
Both approaches did not work. I guess, due to the
The only working alternative for me was an direct update of https://github.com/ruby-git/ruby-git/blob/master/lib/git/lib.rb#L953: - git_cmd = "#{Git::Base.config.binary_path} #{global_opts} #{cmd} #{opts} #{redirect} 2>&1"
+ git_cmd = "#{Git::Base.config.binary_path} #{global_opts} -c color.ui=false #{cmd} #{opts} #{redirect} 2>&1" Not sure, which approach you would prefer. Update: this would also work for me: global_opts = global_opts.flatten.map {|s| escape(s) }.join(' ')
+ global_opts << " -c color.ui=false"
git_cmd = "#{Git::Base.config.binary_path} #{global_opts} #{cmd} #{opts} #{redirect} 2>&1" |
Let me know if this works for you. Adding this line worked for me:
I tested by setting the global
And then ran in a irb session to test:
You can see the command ran was:
When I ran |
What is |
@jcouball, thank you for the hint. I seems there was another issue on my side which resulted in the error. I now tried your approach with I will update the PR in a second.
That's a Rake task we created on our side to build SemanticVersioning into our git workflow. Hence, the |
2deb521
to
b13537c
Compare
Everything is looking good, but the DCO sign-off isn't correct in your commit. In the DCO section of the "Some checks were not successful" section below, click on the "Details" like for instructions to amend the commit with the right information. Once both checks complete successfully, I'll approve and merge this PR. |
Signed-off-by: Marcel Hoyer <m.hoyer@cid.com>
Sorry for the inconvenience. I hope it's now okay so far? Thank you for the support, @jcouball. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved. Thank you for your contribution, Marcel!
…es (ruby-git#427) Signed-off-by: Marcel Hoyer <m.hoyer@cid.com>Signed-off-by: Agora Security <github@agora-security.com>
current_branch
contains color escape codesSimilar to #30 I just found an issue with
ruby-git
when trying to match the string returned fromcurrent_branch
with e.g."master"
. I just recently found this issue and I guess it's related to a recent update of mygit
on my machine which came in just recently.Your environment
git@2.24.0.windows.2
ruby-git@1.5.0
(also had1.3.0
before - same issue)ruby@2.3.1p112 (2016-04-26 revision 54768) [i386-mingw32]
Steps to reproduce
Hence,
"\e[32mmaster\e[m"
is not equal to"master"
.Expected behaviour
git.current_branch
should return the string of the current branch without coloring.In fact, the underlying run of
git branch
should include--no-color
option (which is a nested call insidebranches_all
).Actual behaviour
git.current_branch
contains"\e[32m"
color escape codes.Your checklist for this pull request
🚨Please review the guidelines for contributing to this repository.