Skip to content

Commit

Permalink
Try it with remote_ref
Browse files Browse the repository at this point in the history
  • Loading branch information
bodymindarts committed Jul 21, 2021
1 parent e8217b8 commit 1d0d7a6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
4 changes: 3 additions & 1 deletion ci/release_notes.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Empty - please add release notes here
## Bug Fix

- attempt to fix push to branch
44 changes: 24 additions & 20 deletions src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,31 +114,35 @@ impl Repo {
let head_commit = self
.inner
.reference_to_annotated_commit(&self.inner.head()?)?;
if let Ok(remote_ref) = self
let remote_ref = self
.inner
.resolve_reference_from_short_name(&format!("origin/{}", branch))
{
let remote_commit = self.inner.reference_to_annotated_commit(&remote_ref)?;
let mut rebase_options = RebaseOptions::new();
let mut merge_options = MergeOptions::new();
merge_options.fail_on_conflict(true);
rebase_options.merge_options(merge_options);
let mut rebase = self.inner.rebase(
Some(&head_commit),
Some(&remote_commit),
None,
Some(&mut rebase_options),
)?;
let sig = Signature::now("Cepler", "bot@cepler.dev")?;
while let Some(_) = rebase.next() {
rebase.commit(None, &sig, None)?;
}
rebase.finish(None)?;
.resolve_reference_from_short_name(&format!("origin/{}", branch))?;
let remote_commit = self.inner.reference_to_annotated_commit(&remote_ref)?;

let mut rebase_options = RebaseOptions::new();
let mut merge_options = MergeOptions::new();
merge_options.fail_on_conflict(true);
rebase_options.merge_options(merge_options);
let mut rebase = self.inner.rebase(
Some(&head_commit),
Some(&remote_commit),
None,
Some(&mut rebase_options),
)?;
let sig = Signature::now("Cepler", "bot@cepler.dev")?;
while let Some(_) = rebase.next() {
rebase.commit(None, &sig, None)?;
}
rebase.finish(None)?;

let mut push_options = PushOptions::new();
push_options.remote_callbacks(remote_callbacks(private_key));
remote.push(
&[format!("{}:{}", head_commit.refname().unwrap(), branch)],
&[format!(
"{}:{}",
head_commit.refname().unwrap(),
remote_ref.name().unwrap()
)],
Some(&mut push_options),
)?;
Ok(())
Expand Down

0 comments on commit 1d0d7a6

Please sign in to comment.