summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyborus04 <87248184+Cyborus04@users.noreply.github.com>2023-07-11 19:27:44 +0200
committerCyborus04 <87248184+Cyborus04@users.noreply.github.com>2023-07-11 19:27:44 +0200
commit59a04601b607ade03ac5d60be36d462a3f2d5156 (patch)
tree33b192610b432cbd1a5ad4b52cefbae82b105ca4
parentadd `repo browse` (diff)
downloadforgejo-cli-59a04601b607ade03ac5d60be36d462a3f2d5156.tar.xz
forgejo-cli-59a04601b607ade03ac5d60be36d462a3f2d5156.zip
choose upstream name in `repo create`
-rw-r--r--src/main.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index 78bca92..1ce9604 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -37,9 +37,9 @@ pub enum RepoCommand {
private: bool,
/// Sets the new repo to be the `origin` remote of the current local repo.
#[clap(long, short)]
- set_upstream: bool,
+ set_upstream: Option<String>,
/// Pushes the current branch to the default branch on the new repo.
- /// Implies `--set-upstream`
+ /// Implies `--set-upstream=origin` (setting upstream manual overrides this)
#[clap(long, short)]
push: bool
},
@@ -87,7 +87,7 @@ async fn main() -> eyre::Result<()> {
description,
private,
- set_upstream,
+ mut set_upstream,
push,
} => {
// let (host_domain, host_keys, repo) = keys.get_current_host_and_repo().await?;
@@ -111,11 +111,13 @@ async fn main() -> eyre::Result<()> {
let new_repo = api.create_repo(repo_spec).await?;
eprintln!("created new repo at {}", url.join(&format!("{}/{}", user.name, repo))?);
- if set_upstream || push {
+ let upstream = set_upstream.as_deref().unwrap_or("origin");
+
+ if set_upstream.is_some() || push {
let status = tokio::process::Command::new("git")
.arg("remote")
.arg("add")
- .arg("origin")
+ .arg(upstream)
.arg(new_repo.clone_url.as_str())
.status()
.await?;
@@ -128,7 +130,7 @@ async fn main() -> eyre::Result<()> {
let status = tokio::process::Command::new("git")
.arg("push")
.arg("-u")
- .arg("origin")
+ .arg(upstream)
.arg("main")
.status()
.await?;