git2 箱没有直接的方法来执行“git pull”操作。
use std::fs;
use std::fs::File;
use std::io::{stderr, stdout, Write};
use std::path::Path;
use git2::{Commit, Error, Index, MergeOptions, ObjectType, Repository, ResetType};
struct Repo {
url: &'static str,
path: &'static str,
branch: &'static str,
}
impl Repo {
fn reset(&self, path: &Path) {
let repo = match Repository::open(path) {
Ok(repo) => repo,
Err(e) => panic!("Failed to open: {}", e),
};
repo.reset(
&repo.revparse_single("HEAD").unwrap(),
ResetType::Hard,
None,
)
.unwrap();
}
fn clone(&self) {
let repo = match Repository::clone(self.url, self.path) …Run Code Online (Sandbox Code Playgroud) 我阅读了 Cargo 手册中有关补丁选项的信息,但我仍然不清楚。
是否可以指示货运:
自己制作项目分支是唯一的方法吗?