summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyborus <cyborus@noreply.codeberg.org>2024-12-09 03:11:04 +0100
committerCyborus <cyborus@noreply.codeberg.org>2024-12-09 03:11:04 +0100
commit08e9fa2dce45d4f87cf2c658ceca209c1011f039 (patch)
treea175843e9a8b0c47b33fc7eee6623eaf03c499b0
parentMerge pull request 'fix: detaching when using `browse`' (#143) from dataCobra... (diff)
parentfeat: use `Repository::discover` to open local repo (diff)
downloadforgejo-cli-08e9fa2dce45d4f87cf2c658ceca209c1011f039.tar.xz
forgejo-cli-08e9fa2dce45d4f87cf2c658ceca209c1011f039.zip
Merge pull request 'use `Repository::discover` instead of `open`' (#144) from git-in-subdir into main
Reviewed-on: https://codeberg.org/Cyborus/forgejo-cli/pulls/144
-rw-r--r--src/prs.rs8
-rw-r--r--src/repo.rs6
2 files changed, 7 insertions, 7 deletions
diff --git a/src/prs.rs b/src/prs.rs
index 244d79b..ecce467 100644
--- a/src/prs.rs
+++ b/src/prs.rs
@@ -409,7 +409,7 @@ impl PrCommand {
eyre::eyre!("can't figure what repo to access, try specifying with `--repo`")
}
Checkout { .. } => {
- if git2::Repository::open(".").is_ok() {
+ if git2::Repository::discover(".").is_ok() {
eyre::eyre!("can't figure out what repo to access, try setting a remote tracking branch")
} else {
eyre::eyre!("pr checkout only works if the current directory is a git repo")
@@ -924,7 +924,7 @@ async fn create_pr(
_ if agit => None,
Some(head) => Some(head),
None => {
- let local_repo = git2::Repository::open(".")?;
+ let local_repo = git2::Repository::discover(".")?;
let head = local_repo.head()?;
eyre::ensure!(
head.is_branch(),
@@ -1241,7 +1241,7 @@ async fn checkout_pr(
pr: PrNumber,
branch_name: Option<String>,
) -> eyre::Result<()> {
- let local_repo = git2::Repository::open(".").unwrap();
+ let local_repo = git2::Repository::discover(".").unwrap();
let mut options = git2::StatusOptions::new();
options.include_ignored(false);
@@ -1601,7 +1601,7 @@ async fn guess_pr(
repo: &RepoName,
api: &Forgejo,
) -> eyre::Result<forgejo_api::structs::PullRequest> {
- let local_repo = git2::Repository::open(".")?;
+ let local_repo = git2::Repository::discover(".")?;
let head = local_repo.head()?;
eyre::ensure!(head.is_branch(), "head is not on branch");
let local_branch = git2::Branch::wrap(head);
diff --git a/src/repo.rs b/src/repo.rs
index 424470f..adfde12 100644
--- a/src/repo.rs
+++ b/src/repo.rs
@@ -78,7 +78,7 @@ impl RepoInfo {
let (remote_url, remote_repo_name) = {
let mut out = (None, None);
- if let Ok(local_repo) = git2::Repository::open(".") {
+ if let Ok(local_repo) = git2::Repository::discover(".") {
let mut name = remote.map(|s| s.to_owned());
// if there's only one remote, use that
@@ -557,7 +557,7 @@ pub async fn create_repo(
push: bool,
) -> eyre::Result<()> {
if remote.is_some() || push {
- let repo = git2::Repository::open(".")?;
+ let repo = git2::Repository::discover(".")?;
let upstream = remote.as_deref().unwrap_or("origin");
if repo.find_remote(upstream).is_ok() {
@@ -586,7 +586,7 @@ pub async fn create_repo(
println!("created new repo at {}", html_url);
if remote.is_some() || push {
- let repo = git2::Repository::open(".")?;
+ let repo = git2::Repository::discover(".")?;
let upstream = remote.as_deref().unwrap_or("origin");
let clone_url = new_repo