This adds the --vcs option for rye init, which is intended to act just like cargo init --vcs option.
Usage:
rye init --vcs [git | mercurial | none]
Default can be configured in ~/.rye/config.toml
[default]
vcs = "mercurial"
When not specified, or when git specified, current behavior is preserved. When mercurial is specified, a mercurial VCS is initialized unless the WD is already in a mercurial VCS, and a hgignore file is created. If none is specified via option or default, no VCS is initialized and no ignore templates processed.
VCS dependent operations are factored into a vcs module. To add another VCS, implement the VCSInfo trait methods for it and add a new value to the ProjectVCS enum, mapping the new trait methods to the new match cases.
One new behavior is that if the VCS email is set but the username isn't, the username will be defaulted to "Unknown". If the username is set but the email isn't, I preserved the current behavior of setting email to "unknown@domain.invalid".
Test Plan
Tested on: Windows 11 Home
Existing tests: 2 failed, 30 passed
failures:
publish_outside_project
basic_tool_behavior
I think these are snapshot assertions, need to review with maintainers whether this is expected.
Unit tests check non-templating VCSInfo methods for Git and Mercurial.
Manually regressed behavior:
rye init results in git VCS, gitignore file
rye init results in no git init if inside git working dir already
Manually validated new behavior:
rye init --vcs mercurial results in mercurial VCS, hgignore file
rye init --vcs git results in current behaviors
config.toml allows vcs default config
rye init with vcs = "mercurial" in ~/.rye/config.toml results in mercurial VCS and hgnore file.
rye init with vcs = "git" in ~/.rye/config.toml results in current behavior
rye init --vcs mercurial in subdir of existing mercurial working directory results in no new init
rye init --vcs mercurial when with vcs = "git" in ~/.rye/config.toml results in mercurial VCS, hgignore file
rye init --vcs unexpected causes error "error: one of the values isn't valid for an argument"
rye init with vcs = "unexpected" in ~/.rye/config.toml results in git VCS and gitignore file.
rye init with --vcs none results in no ignore files or VCS repo
author and email metadata are set from local config values for mercurial, last returned values for git (which are local in my test case).
This adds the --vcs option for rye init, which is intended to act just like cargo init --vcs option.
Usage:
Default can be configured in ~/.rye/config.toml
When not specified, or when git specified, current behavior is preserved. When mercurial is specified, a mercurial VCS is initialized unless the WD is already in a mercurial VCS, and a hgignore file is created. If none is specified via option or default, no VCS is initialized and no ignore templates processed.
VCS dependent operations are factored into a vcs module. To add another VCS, implement the VCSInfo trait methods for it and add a new value to the ProjectVCS enum, mapping the new trait methods to the new match cases.
One new behavior is that if the VCS email is set but the username isn't, the username will be defaulted to "Unknown". If the username is set but the email isn't, I preserved the current behavior of setting email to "unknown@domain.invalid".
Test Plan
Tested on: Windows 11 Home Existing tests: 2 failed, 30 passed failures:
Unit tests check non-templating VCSInfo methods for Git and Mercurial.
Manually regressed behavior:
Manually validated new behavior:
author and email metadata are set from local config values for mercurial, last returned values for git (which are local in my test case).