Skip to content

Mount the gitconfig at the container user's home directory - #365

Merged
tfoote merged 2 commits into
osrf:mainfrom
Shriraj1901:fix-git-gitconfig-home-337
Nov 11, 2026
Merged

tfoote merged 2 commits into
osrf:mainfrom
Shriraj1901:fix-git-gitconfig-home-337

Conversation

@Shriraj1901

Copy link
Copy Markdown
Contributor

The git extension guessed the target as /home//.gitconfig, which does not match the home directory the user extension creates in the container when the host home is not /home/, e.g. /root for root. Use the same home directory logic as the user extension.

Fixes #337

The git extension guessed the target as /home/<host username>/.gitconfig,
which does not match the home directory the user extension creates in the
container when the host home is not /home/<name>, e.g. /root for root.
Use the same home directory logic as the user extension.

Fixes osrf#337
@Shriraj1901
Shriraj1901 requested a review from tfoote as a code owner October 29, 2026 06:52

@tfoote tfoote left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks this is good to consolidate the logic together and make sure it stays in sync.

Can you look into making this cleaner with a staticmethod if possible so we don't end up with Extensions being created just to share their cli parsing logic?

Comment thread src/rocker/git_extension.py Outdated
if 'user_override_name' in cli_args and cli_args['user_override_name']:
username = cli_args['user_override_name']
user_gitconfig_target = '/home/%(username)s/.gitconfig' % locals()
homedir = User().get_home_dir(cli_args)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first reaction here was that this should potentially be a staticmethod or a classmethod rather than a member method. In particular it doesn't make sense to have the Git extension creating a User extension temporarily just to call one argument parsing function from it. Especially when it's being default constructed and then immediately drops out of scope. So we're clearly not saving or storing any state.

The Git extension no longer builds a User extension just to read the home directory.

@tfoote tfoote left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks this is great to make consistent.

@tfoote
tfoote merged commit 5470343 into osrf:main Nov 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'Git' extension assumes home directory is in /home

2 participants