-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
feat: read global and system git config #1779
base: main
Are you sure you want to change the base?
Conversation
Hi, I just looked at your code, especially the GitConfigManager. I am not sure that hard coding the config paths depending on the platform is the best approach. The GitConfigManager is called with a filesystem, which is an abstraction and can have different implementations. You can use for example a zip-backed readonly implementation for unit test (the ZipFS preserves timestamps, by the way). Depending on the platform where the node is running you search inside this filesystem for git configs with different paths. The config paths depend on the filesystem you are working with not on the platform where node is running. This can be the the same but it does not have to. |
@dead-end I think figuring out what type of "fake" FS is |
@jayree I think this is reason why the issue was open for such a long time. By the way, the fix with the timestamps has a similar issue. The switch in the Filesystem.js assumes that filesystem implementation supports bigint if it is not running in the browser, which is not necessarily true.
I think the biggest problem with your implementation is, that you cannot change the hard coded values. What we are interested in are some environment variables:
Maybe it is a solution to pass an optional map of environment variables to the constructor of the filesystem wrapper and compute a hard code map from the platform as a default. Then you can use something like You can provide three functions If a user uses ZipFS with a Mac style content he can use |
A simpler way is to use the optional env map for the filesystem constructor and expose the platform env as a fallback and simply use I think that would be my perverted solution compared to the other. |
I also think that detecting the platform and hardcoding the paths is a wrong idea. Please use what I suggested in #236 some kind of extension that allows you to set the path to global git config. The current implementation of isomorphic-git doesn't have plugins anymore. So I think that the best would be to use the option:
or maybe const settings = {
dir: '/home/jcubic/repo',
globalConfig: '/home/jcubic/.gitconfig',
url: '....'
}
await git.clone({...settings });
await fs.writeFile('/home/jcubic/repo/xxx', 'xxxx');
git.add({...settings, filepath: '...'); |
8c54586
to
1d571bc
Compare
80fe9a5
to
56478f1
Compare
5b2bc4f
to
38cf540
Compare
@jcubic While I understand that your proposal may serve its purpose in browser use cases where reliance on file system (FS) abstraction is necessary, I fail to see the advantages of referencing a "global" git configuration in a scenario where you have complete control over the FS content, abstraction and most importend no native git installation. However, for CLI scenarios it is critical to depend on the system and global Git configuration and to follow the goal of achieving 100% interoperability with the canonical Git implementation in Isomorphic-Git. Of cause, hardcoded file paths are bad, but these paths are hardcoded in the git binary as well. So the question is, do you want to support native Git Cli scenarios where |
I don't think that canonical git hardcoded the path on different systems. I think they use |
@jcubic thats correct for the global config but the system config is hardcoded via |
But using |
I'm adding logic to read global and system git config:
__tests__/test-X.js
if possible