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

Add rudimentary parser for Git config files #50

Merged
merged 6 commits into from
Apr 3, 2022
Merged

Conversation

OlivierNicole
Copy link
Collaborator

Parsing .git/config should be useful to get the remote URLs, and hence the project name in Gitlab (the project name, or its ID, is needed to perform project-related requests to the API).

Is it a nice parser? No. Does it already exist elsewhere in a better version? Probably, although I couldn't find it. Git config files seem to be a form of INI files.

For now, nested sections are not supported properly. (They will parse, but the result will not be a hierarchy of sections.)

cli/gitconfig_types.mli Outdated Show resolved Hide resolved
cli/gitconfig_types.mli Outdated Show resolved Hide resolved
cli/test_gitconfig.ml Outdated Show resolved Hide resolved
cli/test_gitconfig.ml Outdated Show resolved Hide resolved
@OlivierNicole
Copy link
Collaborator Author

I implemented @maiste's suggestions, and implemented utility functions to find .git/config and read the project name from it.

@OlivierNicole
Copy link
Collaborator Author

Things are probably still a bit brittle, there may be corner cases in the parser or in the project name extractor that I didn't consider, but I think it can be a decent start.

@tmcgilchrist
Copy link
Owner

Thanks @OlivierNicole I'll merge this and people can create PRs for the various commands that should use this to guess the right project to use.

@tmcgilchrist tmcgilchrist merged commit 0e9dae3 into master Apr 3, 2022
@tmcgilchrist tmcgilchrist deleted the parse_gitconfig branch April 3, 2022 23:25
tmcgilchrist added a commit to tmcgilchrist/opam-repository that referenced this pull request Apr 4, 2022
CHANGES:

## Added
 * Various changes to rework lab cli client. (tmcgilchrist/ocaml-gitlab#50 tmcgilchrist/ocaml-gitlab#51 @maiste @tmcgilchrist @OlivierNicole)

## Bug fixes
 * Strip api/v4 from authorize and token url during OAuth. (tmcgilchrist/ocaml-gitlab#48 @tmcgilchrist)
 * Serialise milestone_id is an int. (tmcgilchrist/ocaml-gitlab#48 @tmcgilchrist)
 * Various merge_request webhook deserialisation fixes. (tmcgilchrist/ocaml-gitlab#47 @tmcgilchrist)
 * Fix incorrect field name, detected with atdgen 2.3.x (tmcgilchrist/ocaml-gitlab#46 @mjambon)
 * Fix commit_short_webhook prefix typo (tmcgilchrist/ocaml-gitlab#45 @MisterDA)
 * Update GHA to use windows-2022  (tmcgilchrist/ocaml-gitlab#44 @MisterDA)
 * Fix subcommands names and document env vars (tmcgilchrist/ocaml-gitlab#44 @MisterDA)
 * Document GITLAB_ env vars via Cmdliner (tmcgilchrist/ocaml-gitlab#44 @MisterDA)
 * Update cmdliner 1.1.0 API (tmcgilchrist/ocaml-gitlab#41 @MisterDA)
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.

3 participants