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

Use dugite system config #563

Merged
merged 5 commits into from
May 23, 2024
Merged

Use dugite system config #563

merged 5 commits into from
May 23, 2024

Conversation

niik
Copy link
Member

@niik niik commented May 21, 2024

ref: desktop/dugite-native#508

This will cause dugite to set the GIT_CONFIG_SYSTEM (unless set already) to point to the newly created system config in dugite-native. This config file will in turn include the actual system config (/etc/gitconfig).

As part of this change I've ensured that all methods that modify the env record that ends up being passed to Git operate on the provided env joined with process.env. This will allow callers to set their own GIT_CONFIG_SYSTEM without having to resort to modifying the current process' environment.

I've also updated the env type to be a more specific Record type instead of the old object type.

Note that we can't merge this until we've published a new version of dugite-native and incorporated it into dugite.

@niik niik requested a review from sergiou87 May 21, 2024 13:57
@niik niik mentioned this pull request May 21, 2024
if (process.env.GIT_EXEC_PATH != null) {
return path.resolve(process.env.GIT_EXEC_PATH)
function resolveGitExecPath(env: Record<string, string | undefined>): string {
if (env.GIT_EXEC_PATH != null) {
Copy link
Member

Choose a reason for hiding this comment

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

Should this be compared with undefined now? (although I see the != instead of !==)

Suggested change
if (env.GIT_EXEC_PATH != null) {
if (env.GIT_EXEC_PATH != undefined) {

Copy link
Member Author

Choose a reason for hiding this comment

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

I went with a simple if (env.GIT_EXEC_PATH) instead, let me know if you have a strong preference for !== undefined. In this case I think the empty string comparison gained by a truthy check makes sense, we don't want to resolve for an empty string.

@@ -109,6 +103,10 @@ export function setupEnvironment(environmentVariables: NodeJS.ProcessEnv): {
}
}

if (process.platform !== 'win32' && !env.GIT_CONFIG_SYSTEM) {
Copy link
Member

Choose a reason for hiding this comment

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

We should probably add a comment here explaining why only on non-Windows platforms 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call

@niik niik requested a review from sergiou87 May 22, 2024 09:00
Copy link
Member

@sergiou87 sergiou87 left a comment

Choose a reason for hiding this comment

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

Thanks for those changes!

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.

2 participants