-
Notifications
You must be signed in to change notification settings - Fork 148
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
Conversation
lib/git-environment.ts
Outdated
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) { |
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.
Should this be compared with undefined
now? (although I see the !=
instead of !==
)
if (env.GIT_EXEC_PATH != null) { | |
if (env.GIT_EXEC_PATH != undefined) { |
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.
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) { |
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.
We should probably add a comment here explaining why only on non-Windows platforms 🤔
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.
Good call
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.
Thanks for those changes!
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 withprocess.env
. This will allow callers to set their ownGIT_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 oldobject
type.Note that we can't merge this until we've published a new version of dugite-native and incorporated it into dugite.