Skip to content

Commit 4729175

Browse files
committed
Auto merge of #3842 - pwoolcoc:add-pijul-vcs-support, r=alexcrichton
Add Pijul support to Cargo [Pijul](https://pijul.org) is a version control system written in Rust. This commit adds the ability to create a cargo project using pijul as the vcs for the project. To use it, run `cargo new my-awesome-project --vcs=pijul`
2 parents 35bf210 + 2b31978 commit 4729175

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

src/bin/new.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Usage:
2727
Options:
2828
-h, --help Print this message
2929
--vcs VCS Initialize a new repository for the given version
30-
control system (git or hg) or do not initialize any version
30+
control system (git, hg, or pijul) or do not initialize any version
3131
control at all (none) overriding a global configuration.
3232
--bin Use a binary (application) template
3333
--lib Use a library template

src/cargo/ops/cargo_new.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ use git2::Config as GitConfig;
1010
use term::color::BLACK;
1111

1212
use core::Workspace;
13-
use util::{GitRepo, HgRepo, CargoResult, human, ChainError, internal};
13+
use util::{GitRepo, HgRepo, PijulRepo, CargoResult, human, ChainError, internal};
1414
use util::{Config, paths};
1515

1616
use toml;
1717

1818
#[derive(Clone, Copy, Debug, PartialEq)]
19-
pub enum VersionControl { Git, Hg, NoVcs }
19+
pub enum VersionControl { Git, Hg, Pijul, NoVcs }
2020

2121
pub struct NewOptions<'a> {
2222
pub version_control: Option<VersionControl>,
@@ -45,6 +45,7 @@ impl Decodable for VersionControl {
4545
Ok(match &d.read_str()?[..] {
4646
"git" => VersionControl::Git,
4747
"hg" => VersionControl::Hg,
48+
"pijul" => VersionControl::Pijul,
4849
"none" => VersionControl::NoVcs,
4950
n => {
5051
let err = format!("could not decode '{}' as version control", n);
@@ -331,10 +332,15 @@ pub fn init(opts: NewOptions, config: &Config) -> CargoResult<()> {
331332
num_detected_vsces += 1;
332333
}
333334

335+
if fs::metadata(&path.join(".pijul")).is_ok() {
336+
version_control = Some(VersionControl::Pijul);
337+
num_detected_vsces += 1;
338+
}
339+
334340
// if none exists, maybe create git, like in `cargo new`
335341

336342
if num_detected_vsces > 1 {
337-
bail!("both .git and .hg directories found \
343+
bail!("more than one of .hg, .git, or .pijul directories found \
338344
and the ignore file can't be \
339345
filled in as a result, \
340346
specify --vcs to override detection");
@@ -401,6 +407,11 @@ fn mk(config: &Config, opts: &MkOptions) -> CargoResult<()> {
401407
}
402408
paths::append(&path.join(".hgignore"), ignore.as_bytes())?;
403409
},
410+
VersionControl::Pijul => {
411+
if !fs::metadata(&path.join(".pijul")).is_ok() {
412+
PijulRepo::init(path, config.cwd())?;
413+
}
414+
},
404415
VersionControl::NoVcs => {
405416
fs::create_dir_all(path)?;
406417
},

src/cargo/util/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub use self::rustc::Rustc;
1717
pub use self::sha256::Sha256;
1818
pub use self::to_semver::ToSemver;
1919
pub use self::to_url::ToUrl;
20-
pub use self::vcs::{GitRepo, HgRepo};
20+
pub use self::vcs::{GitRepo, HgRepo, PijulRepo};
2121
pub use self::read2::read2;
2222

2323
pub mod config;

src/cargo/util/vcs.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use util::{CargoResult, process};
66

77
pub struct HgRepo;
88
pub struct GitRepo;
9+
pub struct PijulRepo;
910

1011
impl GitRepo {
1112
pub fn init(path: &Path, _: &Path) -> CargoResult<GitRepo> {
@@ -28,3 +29,9 @@ impl HgRepo {
2829
}
2930
}
3031

32+
impl PijulRepo {
33+
pub fn init(path: &Path, cwd: &Path) -> CargoResult<PijulRepo> {
34+
process("pijul").cwd(cwd).arg("init").arg(path).exec()?;
35+
Ok(PijulRepo)
36+
}
37+
}

0 commit comments

Comments
 (0)