Skip to content

Commit

Permalink
Merge pull request #210 from kitsuyui/fix-mure-refresh-in-subdirectory
Browse files Browse the repository at this point in the history
Fix: mure refresh does not work in subdirectories
  • Loading branch information
kitsuyui authored May 28, 2023
2 parents 2123985 + 9365d27 commit b0fffad
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/app/refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::path::PathBuf;

use git2::Repository;

use crate::config::Config;
use crate::config::{Config, ConfigSupport};
use crate::gh::get_default_branch;
use crate::git::{PullFastForwardStatus, RepositorySupport};
use crate::mure_error::Error;
Expand All @@ -19,13 +19,11 @@ pub fn refresh_main(
if all {
refresh_all(config, verbosity)?;
} else {
let current_dir = std::env::current_dir()?;
let Some(current_dir) = current_dir.to_str() else {
return Err(Error::from_str("failed to get current dir"));
};
// If no repository is specified, use the current directory
let repo_path = get_git_repository_from_current_dir(config)?;
let repo_path = match repository {
Some(repo) => repo,
None => current_dir.to_string(),
None => repo_path.to_string_lossy().to_string(),
};
match refresh(&repo_path, verbosity) {
Ok(r) => {
Expand All @@ -39,6 +37,12 @@ pub fn refresh_main(
Ok(())
}

pub fn get_git_repository_from_current_dir(config: &Config) -> Result<PathBuf, Error> {
let current_dir = std::env::current_dir()?;
let repo = Repository::discover_path(current_dir, &config.base_path())?;
Ok(repo)
}

#[derive(Debug)]
pub enum RefreshStatus {
DoNothing(Reason),
Expand Down

0 comments on commit b0fffad

Please sign in to comment.