mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-02 07:53:55 +03:00
workaround libgit2 limitation of not pushing wildcards: explicitly pushing all ref/gitbutler/..
refs
This commit is contained in:
parent
ed8606d5e1
commit
fe0368219f
@ -397,6 +397,13 @@ impl Repository {
|
||||
.map(|iter| iter.map(|reference| reference.map(Into::into).map_err(Into::into)))
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn references_glob(&self, glob: &str) -> Result<impl Iterator<Item = Result<Reference>>> {
|
||||
self.0
|
||||
.references_glob(glob)
|
||||
.map(|iter| iter.map(|reference| reference.map(Into::into).map_err(Into::into)))
|
||||
.map_err(Into::into)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct CheckoutTreeBuidler<'a> {
|
||||
|
@ -345,7 +345,7 @@ impl Repository {
|
||||
pub fn push_to_gitbutler_server(
|
||||
&self,
|
||||
user: Option<&users::User>,
|
||||
ref_spec: &str,
|
||||
ref_specs: &[&str],
|
||||
) -> Result<(), RemoteError> {
|
||||
let url = self
|
||||
.project
|
||||
@ -390,12 +390,12 @@ impl Repository {
|
||||
.map_err(|e| RemoteError::Other(e.into()))?;
|
||||
|
||||
remote
|
||||
.push(&[ref_spec], Some(&mut push_options))
|
||||
.push(ref_specs, Some(&mut push_options))
|
||||
.map_err(|e| RemoteError::Other(e.into()))?;
|
||||
|
||||
tracing::debug!(
|
||||
project_id = %self.project.id,
|
||||
%ref_spec,
|
||||
ref_spec = ref_specs.join(" "),
|
||||
bytes = bytes_pushed.load(std::sync::atomic::Ordering::Relaxed),
|
||||
"pushed to gb repo tmp ref",
|
||||
);
|
||||
|
@ -95,7 +95,7 @@ impl HandlerInner {
|
||||
let refspec = format!("+{}:refs/push-tmp/{}", id, project_id);
|
||||
|
||||
project_repository
|
||||
.push_to_gitbutler_server(user.as_ref(), &refspec)
|
||||
.push_to_gitbutler_server(user.as_ref(), &[&refspec])
|
||||
.context("failed to push project to gitbutler")?;
|
||||
|
||||
self.project_store
|
||||
@ -116,14 +116,23 @@ impl HandlerInner {
|
||||
project_repository
|
||||
.push_to_gitbutler_server(
|
||||
user.as_ref(),
|
||||
&format!("+{}:refs/{}", head_id, project_id),
|
||||
&[&format!("+{}:refs/{}", head_id, project_id)],
|
||||
)
|
||||
.context("failed to push project to gitbutler")?;
|
||||
.context("failed to push project (head) to gitbutler")?;
|
||||
|
||||
let refs = gb_refs(&project_repository)?;
|
||||
|
||||
let all_refs = refs
|
||||
.iter()
|
||||
.map(|r| format!("+{}:{}", r, r))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let all_refs = all_refs.iter().map(String::as_str).collect::<Vec<_>>();
|
||||
|
||||
// push all gitbutler refs
|
||||
project_repository
|
||||
.push_to_gitbutler_server(user.as_ref(), "+refs/gitbutler/*:refs/gitbutler/*")
|
||||
.context("failed to push project to gitbutler")?;
|
||||
.push_to_gitbutler_server(user.as_ref(), all_refs.as_slice())
|
||||
.context("failed to push project (all refs) to gitbutler")?;
|
||||
|
||||
//TODO: remove push-tmp ref
|
||||
|
||||
@ -141,3 +150,12 @@ impl HandlerInner {
|
||||
Ok(vec![])
|
||||
}
|
||||
}
|
||||
|
||||
fn gb_refs(project_repository: &project_repository::Repository) -> anyhow::Result<Vec<String>> {
|
||||
Ok(project_repository
|
||||
.git_repository
|
||||
.references_glob("refs/gitbutler/*")?
|
||||
.flatten()
|
||||
.filter_map(|r| r.name().map(ToString::to_string))
|
||||
.collect::<Vec<_>>())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user