Skip to content
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

Additional Git repositories not expanding environment variables like $HOME or ~ #921

Open
1 of 2 tasks
j-lakeman opened this issue Oct 4, 2024 · 6 comments
Open
1 of 2 tasks
Labels
C-bug Something isn't working

Comments

@j-lakeman
Copy link

Erroneous Behavior

Within the [git] section of topgrade.toml,

repos = ["/home/xxx/Documents/Git/*"] is expanded, whereas

repos = ["$HOME/Documents/Git/*"] as well as
repos = ["~/Documents/Git/*"] or
repos = ["$GIT/*"] don't expand.

Expected Behavior

all of the above expand properly (subdirectories of Git/ as well as environment variables)

Steps to reproduce

alter topgrade.toml accordingly

Possible Cause (Optional)

shell or topgrade don't expand variables

Did you run topgrade through Remote Execution

  • Yes
  • No

Configuration file (Optional)

[git]
# How many repos to pull at max in parallel
# max_concurrency = 5

# Additional git repositories to pull
repos = ["~/Documents/Git/*"]

# Don't pull the predefined git repos
# pull_predefined = false

# Arguments to pass Git when pulling Repositories
arguments = "--autostash"

Additional Details

  • Operation System/Version
    openSUSE Tumbleweed, Debian Sid, macOS

  • Installation
    package manager (zypper, apt, brew)

  • Topgrade version (topgrade -V)
    Topgrade 15.0.0

Verbose Output (topgrade -v)

DEBUG Executing command `/usr/bin/git rev-parse --show-toplevel`
Path ~/Documents/Git/* did not contain any git repositories

I should probably also mention that I'm tracking my entire home directory with Git, so the Git directories above are nested.

@j-lakeman j-lakeman added the C-bug Something isn't working label Oct 4, 2024
@SteveLauC
Copy link
Member

Hi, from my test ~ and * will be expanded, environment variables are indeed unsupported, so:

  • $HOME/Documents/Git/*: won't work
  • ~/Documents/Git/*: should work
  • $GIT/*: won't work

@SteveLauC
Copy link
Member

Thanks for searching existing issues before filing a new one:)

Possibly related:

Topgrade currently won't expand the strings configured in custom commands, they are directly passed to user's $SHELL, the shell used by this issue's author, won't expand ~, so this issue happens.

This issue is possibly because a log-in shell won't have the config set in an interactive shell, so it cannot see the $HOME variable.

@SteveLauC
Copy link
Member

environment variables are indeed unsupported

Topgrade uses shellexpand to do the expansion of the shell stuff, like ~, currently, we are using shellexpand::tlide(), which only expands ~, if we replace shellexpand::tlide() with shellexpand::full(), both ~ and environment variables expansion will be supported.

@j-lakeman
Copy link
Author

* `~/Documents/Git/*`: should work

Tried that and it still doesn't work. I should probably also mention that ~/Documents is a symlink in my case which still shouldn't matter right?

Topgrade uses shellexpand to do the expansion of the shell stuff, like ~, currently, we are using shellexpand::tlide(), which only expands ~, if we replace shellexpand::tlide() with shellexpand::full(), both ~ and environment variables expansion will be supported.

Would be awesome if environment variables expansion could be supported!

@j-lakeman
Copy link
Author

Thanks for searching existing issues before filing a new one:)

Of course!

Possibly related:

Topgrade currently won't expand the strings configured in custom commands, they are directly passed to user's $SHELL, the shell used by this issue's author, won't expand ~, so this issue happens.

This issue is possibly because a log-in shell won't have the config set in an interactive shell, so it cannot see the $HOME variable.

Thanks for clarifying!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants