Skip to content

Commit 97ccb65

Browse files
committed
docs(test): Expose git documentation
1 parent 8f88a8a commit 97ccb65

File tree

1 file changed

+39
-39
lines changed
  • crates/cargo-test-support/src

1 file changed

+39
-39
lines changed

crates/cargo-test-support/src/git.rs

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
/*
2-
# Git Testing Support
3-
4-
## Creating a git dependency
5-
`git::new()` is an easy way to create a new git repository containing a
6-
project that you can then use as a dependency. It will automatically add all
7-
the files you specify in the project and commit them to the repository.
8-
Example:
9-
10-
```
11-
let git_project = git::new("dep1", |project| {
12-
project
13-
.file("Cargo.toml", &basic_manifest("dep1", "1.0.0"))
14-
.file("src/lib.rs", r#"pub fn f() { println!("hi!"); } "#)
15-
});
16-
17-
// Use the `url()` method to get the file url to the new repository.
18-
let p = project()
19-
.file("Cargo.toml", &format!(r#"
20-
[package]
21-
name = "a"
22-
version = "1.0.0"
23-
24-
[dependencies]
25-
dep1 = {{ git = '{}' }}
26-
"#, git_project.url()))
27-
.file("src/lib.rs", "extern crate dep1;")
28-
.build();
29-
```
30-
31-
## Manually creating repositories
32-
`git::repo()` can be used to create a `RepoBuilder` which provides a way of
33-
adding files to a blank repository and committing them.
34-
35-
If you want to then manipulate the repository (such as adding new files or
36-
tags), you can use `git2::Repository::open()` to open the repository and then
37-
use some of the helper functions in this file to interact with the repository.
38-
39-
*/
1+
//! # Git Testing Support
2+
//!
3+
//! ## Creating a git dependency
4+
//! `git::new()` is an easy way to create a new git repository containing a
5+
//! project that you can then use as a dependency. It will automatically add all
6+
//! the files you specify in the project and commit them to the repository.
7+
//! Example:
8+
//!
9+
//! ```no_run
10+
//! # use cargo_test_support::project;
11+
//! # use cargo_test_support::basic_manifest;
12+
//! # use cargo_test_support::git;
13+
//! let git_project = git::new("dep1", |project| {
14+
//! project
15+
//! .file("Cargo.toml", &basic_manifest("dep1", "1.0.0"))
16+
//! .file("src/lib.rs", r#"pub fn f() { println!("hi!"); } "#)
17+
//! });
18+
//!
19+
//! // Use the `url()` method to get the file url to the new repository.
20+
//! let p = project()
21+
//! .file("Cargo.toml", &format!(r#"
22+
//! [package]
23+
//! name = "a"
24+
//! version = "1.0.0"
25+
//!
26+
//! [dependencies]
27+
//! dep1 = {{ git = '{}' }}
28+
//! "#, git_project.url()))
29+
//! .file("src/lib.rs", "extern crate dep1;")
30+
//! .build();
31+
//! ```
32+
//!
33+
//! ## Manually creating repositories
34+
//! `git::repo()` can be used to create a `RepoBuilder` which provides a way of
35+
//! adding files to a blank repository and committing them.
36+
//!
37+
//! If you want to then manipulate the repository (such as adding new files or
38+
//! tags), you can use `git2::Repository::open()` to open the repository and then
39+
//! use some of the helper functions in this file to interact with the repository.
4040
4141
use crate::{paths::CargoPathExt, project, Project, ProjectBuilder, SymlinkBuilder};
4242
use std::fs;

0 commit comments

Comments
 (0)