MCPcopy Create free account
hub / github.com/MrBeanCpp/MIT / update_head_commit

Function update_head_commit

src/utils/head.rs:67–79  ·  view source on GitHub ↗

将当前的head指向commit_hash,根据当前的head类型,更新不同的文件 */

(commit_hash: &String)

Source from the content-addressed store, hash-verified

65
66/** 将当前的head指向commit_hash,根据当前的head类型,更新不同的文件 */
67pub fn update_head_commit(commit_hash: &String) {
68 let head = current_head();
69 match head {
70 Head::Branch(branch_name) => {
71 update_branch(&branch_name, commit_hash);
72 }
73 Head::Detached(_) => {
74 let mut head = util::get_storage_path().unwrap();
75 head.push("HEAD");
76 std::fs::write(head, commit_hash).expect("无法写入HEAD");
77 }
78 }
79}
80
81/** 列出本地的branch */
82pub fn list_local_branches() -> Vec<String> {

Callers 2

change_head_to_branchFunction · 0.85
commitFunction · 0.85

Calls 3

current_headFunction · 0.85
update_branchFunction · 0.85
get_storage_pathFunction · 0.85

Tested by

no test coverage detected