elasticdog/transcrypt

Cannot detect transcrypt repo

dimitrov-adrian opened this issue · 4 comments

Get error transcrypt: the current repository is not configured using transcrypt --display command

It seems that it caused when grep is set globally to use colors, then the comparison from get_contexts_from_git_config() the [[ "$name" = "transcrypt.password" ]] do not work since it compare colorized than non-colorized string

jmurty commented

Hi, I assume this problem is occurring because you are using --color=always in a grep alias or similar?

Another option would be to use the --color=auto instead, which should give you better behaviour: coloured output when you run grep yourself in a terminal, but no color code junk when grep is run within scripts like transcrypt.

jmurty commented

With some trial and error I have reproduced this problem by setting the environment variable GREP_OPTIONS='--color=always' which I'm assuming is what you have?

With that envvar set I see the same error as reported.

Adding this line near the top of the transcrypt file fixes it for me, can you confirm whether it solves the problem for you too?

GREP_OPTIONS=""

If this works I'd be happy to add it to transcrypt as a work-around for problematic global settings, since it is a more broadly compatible approach than the one in PR #167

I was trying same approach since GREP_COLORS didn't make any difference for me, but GREP_OPTIONS do the trick.

I was also thinking if doing in bit different way, since grep matching the first part, then if

config_names=$(git config --local --name-only --list | grep transcrypt | cut -d '.' -f2-)
extract_context_name_regex="(${CONTEXT_REGEX}).password"

and the comparison

if [[ "$name" = "password" ]]; then
jmurty commented

I have applied a fix for this in commit #a825f9de0b16084b5e279cf9deaba23ade333b85