Compare commits
1 Commits
48f3bc0199
...
v0.3
| Author | SHA1 | Date | |
|---|---|---|---|
| 102758c25c |
@@ -949,6 +949,10 @@ pub fn run() {
|
||||
.set_upstream(Some(&upstream_branch_name))
|
||||
.unwrap();
|
||||
} else {
|
||||
print_error(&format!(
|
||||
"Remote branch {} not found",
|
||||
&upstream_branch_name
|
||||
));
|
||||
let split_at = upstream_branch_name.find('/').unwrap_or(0);
|
||||
if split_at == 0 || split_at >= upstream_branch_name.len() - 1 {
|
||||
print_error("Tracking branch needs to match the pattern <remote>/<branch_name>");
|
||||
@@ -993,10 +997,7 @@ pub fn run() {
|
||||
);
|
||||
remote
|
||||
.push(&[push_refspec], Some(&mut push_options))
|
||||
.unwrap_or_else(|error| {
|
||||
print_error(&format!("Pushing to {} ({}) failed: {}", remote_name, remote.url().unwrap(), error));
|
||||
process::exit(1);
|
||||
});
|
||||
.unwrap();
|
||||
|
||||
target_branch
|
||||
.set_upstream(Some(&upstream_branch_name))
|
||||
|
||||
23
src/repo.rs
23
src/repo.rs
@@ -10,7 +10,6 @@ use crate::output::*;
|
||||
pub enum RemoteType {
|
||||
Ssh,
|
||||
Https,
|
||||
File,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
@@ -128,14 +127,6 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_file_remote() {
|
||||
assert_eq!(
|
||||
detect_remote_type("file:///somedir"),
|
||||
Some(RemoteType::File)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_invalid_remotes() {
|
||||
assert_eq!(detect_remote_type("https//example.com"), None);
|
||||
@@ -156,6 +147,12 @@ mod tests {
|
||||
fn check_unsupported_protocol_git() {
|
||||
detect_remote_type("git://example.com");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn check_unsupported_protocol_file() {
|
||||
detect_remote_type("file:///");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn detect_remote_type(remote_url: &str) -> Option<RemoteType> {
|
||||
@@ -169,15 +166,15 @@ pub fn detect_remote_type(remote_url: &str) -> Option<RemoteType> {
|
||||
if remote_url.starts_with("https://") {
|
||||
return Some(RemoteType::Https);
|
||||
}
|
||||
if remote_url.starts_with("file://") {
|
||||
return Some(RemoteType::File);
|
||||
}
|
||||
if remote_url.starts_with("http://") {
|
||||
unimplemented!("Remotes using HTTP protocol are not supported");
|
||||
}
|
||||
if remote_url.starts_with("git://") {
|
||||
unimplemented!("Remotes using git protocol are not supported");
|
||||
}
|
||||
if remote_url.starts_with("file://") || remote_url.starts_with('/') {
|
||||
unimplemented!("Remotes using local protocol are not supported");
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
@@ -257,7 +254,7 @@ pub fn clone_repo(
|
||||
&remote.url
|
||||
));
|
||||
match remote.remote_type {
|
||||
RemoteType::Https | RemoteType::File => {
|
||||
RemoteType::Https => {
|
||||
let mut builder = git2::build::RepoBuilder::new();
|
||||
builder.bare(is_worktree);
|
||||
builder.clone(&remote.url, &clone_target)?;
|
||||
|
||||
Reference in New Issue
Block a user