diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/config.rs | 25 | 
1 files changed, 16 insertions, 9 deletions
| diff --git a/src/config.rs b/src/config.rs index 615c0d4..9b37eb1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -43,15 +43,9 @@ impl Config {          let git_config = Repository::open(".")?.config()?; -        let remote = match opt_matches.opt_str("remote") { -            Some(r) => Ok(Some(r)), -            None => match git_config.get_string(&git_config_key("remote")) { -                Err(e) if e.code() == git2::ErrorCode::NotFound => Ok(None), -                r => r.map(|r| Some(r)), -            }, -        }?; - -        let o_r = OwnerRepo::from_remote(remote.as_deref())?; +        let o_r = OwnerRepo::from_remote( +            Self::remote(&opt_matches, &git_config)?.as_deref(), +        )?;          Ok(Config {              github_token: Self::github_token(&opt_matches, &git_config)?, @@ -75,6 +69,19 @@ impl Config {                  },          }      } + +    fn remote( +        opt_matches: &getopts::Matches, +        git_config: &git2::Config, +    ) -> Result<Option<String>, git2::Error> { +        match opt_matches.opt_str("remote") { +            Some(r) => Ok(Some(r)), +            None => match git_config.get_string(&git_config_key("remote")) { +                Err(e) if e.code() == git2::ErrorCode::NotFound => Ok(None), +                r => r.map(|r| Some(r)), +            }, +        } +    }  }  fn git_config_key(key: &str) -> String { | 
