step fifty eight: download remote ref values
This commit is contained in:
parent
1b1af9fac1
commit
70a660e2f5
|
@ -3,10 +3,24 @@ use std::collections::HashMap;
|
|||
#[path = "data.rs"]
|
||||
mod data;
|
||||
|
||||
static REMOTE_REFS_BASE: &'static str = "refs/heads/";
|
||||
static LOCAL_REFS_BASE: &'static str = "refs/remote/";
|
||||
|
||||
pub fn fetch(path: String) {
|
||||
println!("Will fetch the following refs:");
|
||||
for (refname, _) in get_remote_refs(path, "refs/heads").iter() {
|
||||
println!("- {}", refname);
|
||||
// Get refs from server
|
||||
let refs = get_remote_refs(path, REMOTE_REFS_BASE);
|
||||
|
||||
// Update local refs to match server
|
||||
for (remote_name, value) in refs.iter() {
|
||||
let refname = remote_name.trim_start_matches(REMOTE_REFS_BASE);
|
||||
data::update_ref(
|
||||
format!("{}/{}", LOCAL_REFS_BASE, refname),
|
||||
data::RefValue {
|
||||
symbolic: false,
|
||||
value: value.clone(),
|
||||
},
|
||||
true,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue