Skip to content

Commit

Permalink
attach: set origin url (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
fioncat authored Dec 13, 2024
1 parent 66b319b commit d554879
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 66 deletions.
112 changes: 55 additions & 57 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "roxide"
version = "0.17.2"
version = "0.17.3"
edition = "2021"
build = "build.rs"
license = "MIT"
Expand All @@ -23,13 +23,13 @@ aes-gcm = "0.10.3"
anyhow = "1.0.94"
base64 = "0.22.1"
bincode = "1.3.3"
chrono = "0.4.38"
clap = { version = "4.5.22", features = ["derive"] }
chrono = "0.4.39"
clap = { version = "4.5.23", features = ["derive"] }
console = "0.15.8"
dialoguer = "0.11.0"
file-lock = "2.1.11"
glob = "0.3.1"
libc = "0.2.167"
libc = "0.2.168"
num_cpus = "1.16.0"
open = "5.3.1"
pad = "0.1.6"
Expand All @@ -38,8 +38,8 @@ regex = "1.11.1"
reqwest = { version = "0.12.9", features = ["blocking", "json"] }
rpassword = "7.3.1"
scanf = "1.2.1"
semver = "1.0.23"
serde = { version = "1.0.215", features = ["derive"] }
semver = "1.0.24"
serde = { version = "1.0.216", features = ["derive"] }
serde_json = "1.0.133"
sha2 = "0.10.8"
shellexpand = "3.1.0"
Expand Down
8 changes: 8 additions & 0 deletions src/cmd/attach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::cmd::{Completion, Run};
use crate::config::Config;
use crate::exec::Cmd;
use crate::repo::database::{Database, SelectOptions, Selector};
use crate::repo::Repo;
use crate::{confirm, info, utils};

/// Attach the current directory to a repository.
Expand Down Expand Up @@ -71,6 +72,13 @@ impl Run for AttachArgs {
.with_display(format!("Set email to '{}'", email))
.execute()?;
}
if repo.remote_cfg.clone.is_some() {
let url =
Repo::get_clone_url(repo.owner.as_ref(), repo.name.as_ref(), &repo.remote_cfg);
Cmd::git(&["remote", "set-url", "origin", url.as_str()])
.with_display(format!("Set original url to '{}'", url))
.execute()?;
}

info!("Attach current directory to {}", repo.name_with_remote());
repo.append_labels(append_labels);
Expand Down
6 changes: 3 additions & 3 deletions src/repo/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,9 @@ impl Database<'_> {
#[inline]
fn build_repo<'a>(
&'a self,
remote: &'a String,
owner: &'a String,
name: &'a String,
remote: &'a str,
owner: &'a str,
name: &'a str,
bucket: &'a RepoBucket,
) -> Repo<'a> {
Repo {
Expand Down

0 comments on commit d554879

Please sign in to comment.