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 rye init --vcs option to set version control system. Defaults to git, adds mercurial and none options. #1289

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adenyes
Copy link

@adenyes adenyes commented Jul 29, 2024

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 "[email protected]".

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).

Usage:
```
rye init --vcs [git | mercurial]
```
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.
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.

1 participant