Merge pull request #1426 from gitbutlerapp/update-branch-upstream

Update branch upstream
This commit is contained in:
Nikita Galaiko 2023-10-19 15:08:44 +02:00 committed by GitHub
commit 78ed6319fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 8 deletions

View File

@ -968,7 +968,7 @@ fn build_session_tree(gb_repository: &Repository) -> Result<git::Oid> {
// add all files in the working directory to the in-memory index, skipping for matching entries in the repo index
for file_path in
fs::list_files(&gb_repository.session_path()).context("failed to list session files")?
fs::list_files(gb_repository.session_path()).context("failed to list session files")?
{
let file_path = std::path::Path::new(&file_path);
if file_path.starts_with("wd/") {

View File

@ -67,8 +67,8 @@ impl FileOwnership {
let mut hunks = self
.hunks
.iter()
.cloned()
.filter(|hunk| !another.hunks.contains(hunk))
.cloned()
.collect::<Vec<Hunk>>();
another.hunks.iter().for_each(|hunk| {

View File

@ -56,8 +56,8 @@ impl Ownership {
.files
.iter()
.filter(|o| !o.is_full()) // only consider explicit ownership
.cloned()
.find(|o| o.file_path == ownership.file_path);
.find(|o| o.file_path == ownership.file_path)
.cloned();
self.files
.retain(|o| o.is_full() || o.file_path != ownership.file_path);

View File

@ -2116,7 +2116,7 @@ pub fn push(
let branch_reader = branch::Reader::new(&current_session_reader);
let branch_writer = branch::Writer::new(gb_repository);
let mut vbranch = branch_reader
let vbranch = branch_reader
.read(branch_id)
.context("failed to read branch")
.map_err(PushError::Other)?;
@ -2146,10 +2146,12 @@ pub fn push(
project_repository.push(&vbranch.head, &remote_branch, with_force, credentials)?;
vbranch.upstream = Some(remote_branch.clone());
vbranch.upstream_head = Some(vbranch.head);
branch_writer
.write(&vbranch)
.write(&branch::Branch {
upstream: Some(remote_branch.clone()),
upstream_head: Some(vbranch.head),
..vbranch
})
.context("failed to write target branch after push")?;
project_repository.fetch(remote_branch.remote(), credentials)?;