mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
docs(test): Expose git
documentation
This commit is contained in:
parent
8f88a8af31
commit
97ccb653b0
@ -1,42 +1,42 @@
|
|||||||
/*
|
//! # Git Testing Support
|
||||||
# Git Testing Support
|
//!
|
||||||
|
//! ## Creating a git dependency
|
||||||
## Creating a git dependency
|
//! `git::new()` is an easy way to create a new git repository containing a
|
||||||
`git::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
|
||||||
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.
|
||||||
the files you specify in the project and commit them to the repository.
|
//! Example:
|
||||||
Example:
|
//!
|
||||||
|
//! ```no_run
|
||||||
```
|
//! # use cargo_test_support::project;
|
||||||
let git_project = git::new("dep1", |project| {
|
//! # use cargo_test_support::basic_manifest;
|
||||||
project
|
//! # use cargo_test_support::git;
|
||||||
.file("Cargo.toml", &basic_manifest("dep1", "1.0.0"))
|
//! let git_project = git::new("dep1", |project| {
|
||||||
.file("src/lib.rs", r#"pub fn f() { println!("hi!"); } "#)
|
//! 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#"
|
//! // Use the `url()` method to get the file url to the new repository.
|
||||||
[package]
|
//! let p = project()
|
||||||
name = "a"
|
//! .file("Cargo.toml", &format!(r#"
|
||||||
version = "1.0.0"
|
//! [package]
|
||||||
|
//! name = "a"
|
||||||
[dependencies]
|
//! version = "1.0.0"
|
||||||
dep1 = {{ git = '{}' }}
|
//!
|
||||||
"#, git_project.url()))
|
//! [dependencies]
|
||||||
.file("src/lib.rs", "extern crate dep1;")
|
//! dep1 = {{ git = '{}' }}
|
||||||
.build();
|
//! "#, git_project.url()))
|
||||||
```
|
//! .file("src/lib.rs", "extern crate dep1;")
|
||||||
|
//! .build();
|
||||||
## Manually creating repositories
|
//! ```
|
||||||
`git::repo()` can be used to create a `RepoBuilder` which provides a way of
|
//!
|
||||||
adding files to a blank repository and committing them.
|
//! ## Manually creating repositories
|
||||||
|
//! `git::repo()` can be used to create a `RepoBuilder` which provides a way of
|
||||||
If you want to then manipulate the repository (such as adding new files or
|
//! adding files to a blank repository and committing them.
|
||||||
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.
|
//! 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.
|
||||||
|
|
||||||
use crate::{paths::CargoPathExt, project, Project, ProjectBuilder, SymlinkBuilder};
|
use crate::{paths::CargoPathExt, project, Project, ProjectBuilder, SymlinkBuilder};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user