only even try to ff merge when there is something incoming (#554)

* Update pull.rs
This commit is contained in:
Stephan Dilly 2021-03-01 11:10:25 +01:00 committed by GitHub
parent 102b0b31fb
commit dfa4d7789d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -127,19 +127,7 @@ impl PullComponent {
self.git_fetch.last_result()?
{
if err.is_empty() {
let merge_res =
sync::branch_merge_upstream_fastforward(
CWD,
&self.branch,
);
if let Err(err) = merge_res {
self.queue.borrow_mut().push_back(
InternalEvent::ShowErrorMsg(format!(
"merge failed:\n{}",
err
)),
);
}
self.do_merge()?;
} else {
self.queue.borrow_mut().push_back(
InternalEvent::ShowErrorMsg(format!(
@ -154,6 +142,28 @@ impl PullComponent {
Ok(())
}
// check if something is incoming and try a ff merge then
fn do_merge(&self) -> Result<()> {
let branch_compare =
sync::branch_compare_upstream(CWD, &self.branch)?;
if branch_compare.behind > 0 {
let merge_res = sync::branch_merge_upstream_fastforward(
CWD,
&self.branch,
);
if let Err(err) = merge_res {
self.queue.borrow_mut().push_back(
InternalEvent::ShowErrorMsg(format!(
"merge failed:\n{}",
err
)),
);
}
}
Ok(())
}
}
impl DrawableComponent for PullComponent {