cargo_test_support

# Module git

Source
Expand description

## §Git Testing Support

### §Creating a git dependency

`new()` is an easy way to create a new git repository containing a project that you can then use as a dependency. It will automatically add all the files you specify in the project and commit them to the repository.

#### §Example:

    let git_project = git::new("dep1", |project| {
        project
            .file("Cargo.toml", &basic_manifest("dep1", "1.0.0"))
            .file("src/lib.rs", r#"pub fn f() { println!("hi!"); } "#)
    });

    // Use the `url()` method to get the file url to the new repository.
    let p = project()
        .file("Cargo.toml", &format!(r#"
            [package]
            name = "a"
            version = "1.0.0"

            [dependencies]
            dep1 = {{ git = '{}' }}
        "#, git_project.url()))
        .file("src/lib.rs", "extern crate dep1;")
        .build();

### §Manually creating repositories

`repo()` can be used to create a `RepoBuilder` which provides a way of adding files to a blank repository and committing them.

If you want to then manipulate the repository (such as adding new files or tags), you can use `git2::Repository::open()` to open the repository and then use some of the helper functions in this file to interact with the repository.

## Structs§

- RepoBuilder
  Manually construct a `Repository`
- Repository
  See `new`

## Functions§

- add
  (`git2`) Add all files in the working directory to the git index
- add_submodule
  (`git2`) Add a git submodule to the repository
- cargo_uses_gitoxide
  Returns true if gitoxide is globally activated.
- commit
  (`git2`) Commit changes to the git repository
- default_repo_cfg 🔒
- default_search_path 🔒
- init
  (`git2`) Initialize a new repository at the given path.
- new
  Create a new `Project` in a git `Repository`
- new_repo
  Create a new `Project` with access to the `Repository`
- repo
  Create a `RepoBuilder` to build a new git repository.
- tag
  (`git2`) Create a new tag in the git repository