Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

common: Fix remote configuration #263

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion checkout/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub fn execute(options: Options, profile: &profile::Profile) -> anyhow::Result<P
);
Some(*d)
}
[_,_,..] => anyhow::bail!("project has more than one delegate, please specify which one you would like to checkout"),
[_, _, ..] => anyhow::bail!("project has more than one delegate, please specify which one you would like to checkout"),
}
};

Expand Down
12 changes: 4 additions & 8 deletions common/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,13 +512,14 @@ pub fn find_remote(
/// Create a git remote for the given project and peer. This does not save the
/// remote to the git configuration.
pub fn remote(urn: &Urn, peer: &PeerId, name: &str) -> Result<Remote<LocalUrl>, anyhow::Error> {
use librad::git::types::{Flat, Force, GenericRef, Refspec};
use librad::git::types::{Flat, Force, Refspec};
use librad::git_ext::RefspecPattern;

let name = RefLike::try_from(name)?;
let url = LocalUrl::from(urn.clone());
let remote = Remote::new(url, name.clone()).with_fetchspecs(vec![Refspec {
src: Reference::heads(Flat, *peer),
dst: GenericRef::heads(Flat, name),
dst: RefspecPattern::try_from(format!("refs/remotes/{name}/*"))?,
force: Force::True,
}]);

Expand Down Expand Up @@ -554,11 +555,6 @@ pub fn peer_prefix(name: &str) -> String {
format!("{}/{}", PEER_PREFIX, name)
}

pub fn remote_name(name: &str) -> String {
let peer_prefix = peer_prefix(name);
format!("{}/rad", peer_prefix)
}

/// Setup a project remote and tracking branch.
pub struct SetupRemote<'a> {
/// The project.
Expand All @@ -585,7 +581,7 @@ impl<'a> SetupRemote<'a> {
let urn = &self.project.urn;

// TODO: Handle conflicts in remote name.
let mut remote = self::remote(urn, peer, &remote_name(name))?;
let mut remote = self::remote(urn, peer, &peer_prefix(name))?;

// Configure the remote in the repository.
remote.save(repo)?;
Expand Down