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

Rye can update self to a special git branch #864

Merged
merged 3 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ _Unreleased_
- Updating `rye` will now also ensure that the self-venv is updated. Previously
this was deferred until the next `sync`. #863

- The `self update` command now accepts `--branch`. #864

## 0.28.0

Released on 2024-03-07
Expand Down
8 changes: 8 additions & 0 deletions docs/guide/commands/self/update.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ Compile a specific revision:
$ rye self update --rev 08910bc9b3b7c72a3d3ac694c4f3412259161477
```

Compile latest development version:

```
$ rye self update --branch main
```

## Arguments

_no arguments_
Expand All @@ -37,6 +43,8 @@ _no arguments_

* `--rev <REV>`: Update to a specific git rev

* `--branch <BRANCH>`: Update to a specific git branch

* `--force`: Force reinstallation

* `-h, --help`: Print help (see a summary with '-h')
8 changes: 7 additions & 1 deletion rye/src/cli/rye.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ pub struct UpdateCommand {
/// Update to a specific git rev.
#[arg(long, conflicts_with = "tag")]
rev: Option<String>,
/// Update to a specific git branch.
#[arg(long, conflicts_with = "tag", conflicts_with = "rev")]
branch: Option<String>,
/// Force reinstallation
#[arg(long)]
force: bool,
Expand Down Expand Up @@ -192,7 +195,7 @@ fn update(args: UpdateCommand) -> Result<(), Error> {
let current_exe = env::current_exe()?;

// git based installation with cargo
if args.rev.is_some() || args.tag.is_some() {
if args.rev.is_some() || args.tag.is_some() || args.branch.is_some() {
let mut cmd = Command::new("cargo");
let tmp = tempdir()?;
cmd.arg("install")
Expand All @@ -214,6 +217,9 @@ fn update(args: UpdateCommand) -> Result<(), Error> {
} else if let Some(ref tag) = args.tag {
cmd.arg("--tag");
cmd.arg(tag);
} else if let Some(ref branch) = args.branch {
cmd.arg("--branch");
cmd.arg(branch);
}
if args.force {
cmd.arg("--force");
Expand Down