小编Arg*_*olo的帖子

如何使用 Rust git2 crate 执行“git pull”?

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)

git pull rust libgit2

6
推荐指数
1
解决办法
3401
查看次数

是否可以对 Cargo.toml 中的外部代码应用补丁?

我阅读了 Cargo 手册中有关补丁选项的信息,但我仍然不清楚。

是否可以指示货运:

  1. 从该存储库获取代码。
  2. 将此补丁文件 (my_cool_change.patch) 应用于该代码。

自己制作项目分支是唯一的方法吗?

patch rust rust-cargo

5
推荐指数
1
解决办法
614
查看次数

标签 统计

rust ×2

git ×1

libgit2 ×1

patch ×1

pull ×1

rust-cargo ×1