Skip to content

Commit c158dda

Browse files
committed
Add branch.push_to_remote config option
Add branch.push_to_remote config option so that users could configure gps to push to the remote automatically any time they do a gps branch. This is etremely useful when you are using gps locally but the team you are working with doesn't want to use gps. I made this option default to false. In addition to adding this option I also renamed the command line option to control this as well so that it matches in naming and concept. [changelog] added: branch.push_to_remote configuration option <!-- ps-id: ce01645a-cecc-4103-bef2-b864e01f4730 -->
1 parent 39c86b8 commit c158dda

File tree

7 files changed

+12
-8
lines changed

7 files changed

+12
-8
lines changed

src/cli.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ pub struct BranchCmdOpts {
2323
/// Use the provided branch name instead of generating one
2424
#[structopt(short = "n")]
2525
pub branch_name: Option<String>,
26-
/// Create a remote branch of the same name and push
27-
#[structopt(short = "r")]
28-
pub create_remote_branch: bool,
26+
/// Push branch of the same name to the remote
27+
#[structopt(short = "p")]
28+
pub push_to_remote: bool,
2929
}
3030

3131
#[derive(Debug, StructOpt)]

src/commands/branch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ pub fn branch(
66
start_patch_index: usize,
77
end_patch_index_option: Option<usize>,
88
branch_name: Option<String>,
9-
create_remote_branch: bool,
9+
push_to_remote: bool,
1010
color: bool,
1111
) {
1212
match ps::branch(
1313
start_patch_index,
1414
end_patch_index_option,
1515
branch_name,
16-
create_remote_branch,
16+
push_to_remote,
1717
color,
1818
) {
1919
Ok(_) => {}

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn main() {
2323
opts.start_patch_index,
2424
opts.end_patch_index,
2525
opts.branch_name,
26-
opts.create_remote_branch,
26+
opts.push_to_remote,
2727
opt.color,
2828
),
2929
cli::Command::RequestReviewBranch(opts) => {

src/ps/private/config/branch_config_dto.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ use std::option::Option;
55
#[derive(Debug, Deserialize, Clone, Default)]
66
pub struct BranchConfigDto {
77
pub verify_isolation: Option<bool>,
8+
pub push_to_remote: Option<bool>,
89
}
910

1011
impl utils::Mergable for BranchConfigDto {
1112
/// Merge the provided b with self overriding with any present values
1213
fn merge(&self, b: &Self) -> Self {
1314
BranchConfigDto {
1415
verify_isolation: b.verify_isolation.or(self.verify_isolation),
16+
push_to_remote: b.push_to_remote.or(self.push_to_remote),
1517
}
1618
}
1719
}

src/ps/private/config/get_config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ fn apply_request_review_config_defaults(
9595
fn apply_branch_config_defaults(branch_config_dto: &BranchConfigDto) -> PsBranchConfig {
9696
PsBranchConfig {
9797
verify_isolation: branch_config_dto.verify_isolation.unwrap_or(true),
98+
push_to_remote: branch_config_dto.push_to_remote.unwrap_or(false),
9899
}
99100
}
100101

src/ps/private/config/ps_config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub struct PsRequestReviewConfig {
1616
#[derive(Debug)]
1717
pub struct PsBranchConfig {
1818
pub verify_isolation: bool,
19+
pub push_to_remote: bool,
1920
}
2021

2122
#[derive(Debug)]

src/ps/public/branch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub fn branch(
3737
start_patch_index: usize,
3838
end_patch_index_option: Option<usize>,
3939
given_branch_name_option: Option<String>,
40-
create_remote_branch: bool,
40+
push_to_remote: bool,
4141
color: bool,
4242
) -> Result<(), BranchError> {
4343
let repo = git::create_cwd_repo().map_err(BranchError::OpenRepositoryFailed)?;
@@ -102,7 +102,7 @@ pub fn branch(
102102
.map_err(BranchError::CherryPickFailed)?;
103103

104104
// push branch up to remote branch
105-
if create_remote_branch {
105+
if push_to_remote || config.branch.push_to_remote {
106106
// get remote name of current branch (e.g. origin)
107107
let cur_branch_name =
108108
git::get_current_branch(&repo).ok_or(BranchError::CurrentBranchNameMissing)?;

0 commit comments

Comments
 (0)