Skip to content

Commit 1f4d669

Browse files
feat(cli): add ability to get github_master_branch from cli (#197)
Related to #195 Co-authored-by: Sven Over <sp@cedenti.st>
1 parent c5a0d79 commit 1f4d669

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

spr/src/main.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ pub struct Cli {
3737
#[clap(long)]
3838
github_repository: Option<String>,
3939

40+
/// The name of the centrally shared branch into which the pull requests are merged
41+
/// spr.githubMasterBranch)
42+
#[clap(long)]
43+
github_master_branch: Option<String>,
44+
4045
/// prefix to be used for branches created for pull requests (if not given
4146
/// taken from git config spr.branchPrefix, defaulting to
4247
/// 'spr/<GITHUB_USERNAME>/')
@@ -107,6 +112,13 @@ pub async fn spr() -> Result<()> {
107112
None => git_config.get_string("spr.githubRepository"),
108113
}?;
109114

115+
let github_master_branch = match cli.github_master_branch {
116+
Some(v) => Ok::<String, git2::Error>(v),
117+
None => git_config
118+
.get_string("spr.githubMasterBranch")
119+
.or_else(|_| Ok("master".to_string())),
120+
}?;
121+
110122
let branch_prefix = match cli.branch_prefix {
111123
Some(v) => Ok(v),
112124
None => git_config.get_string("spr.branchPrefix"),
@@ -127,9 +139,6 @@ pub async fn spr() -> Result<()> {
127139
let github_remote_name = git_config
128140
.get_string("spr.githubRemoteName")
129141
.unwrap_or_else(|_| "origin".to_string());
130-
let github_master_branch = git_config
131-
.get_string("spr.githubMasterBranch")
132-
.unwrap_or_else(|_| "master".to_string());
133142
let require_approval = git_config
134143
.get_bool("spr.requireApproval")
135144
.ok()

0 commit comments

Comments
 (0)