Init feature; specific .ignore configs

ammkrn
Jul 30, 2021, 12:29 AM
H72JG6HLA7U3XFOUMWF6F3NFSWK5B6ZM6J5ZTILRSXBA7IM6H75AC

Dependencies

  • [2] RUBBHYZ7 Removing unnecessary async/await
  • [3] Q7CHNDXN Init repo with default .ignore file
  • [4] LYTVEPH3 Avoid cloning into an existing path
  • [5] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [6] BZSC7VMY address clippy lints
  • [7] ZBNKSYA6 Fixing a bus error when starting a transaction on a full disk
  • [8] EUZFFJSO Updating Pijul with the latest changes in Libpijul
  • [9] RGJWLQWB When cloning, try to init *before* setting up the path Drop (pijul::commands::clone::RepoPath)
  • [10] SQVWP4LU When clone fails, only remove directories we have created (not other directories)
  • [11] I24UEJQL Various post-fire fixes
  • [12] B3QWIGDE Fixing the Git features with the latest Pijul (+ conflicts in Cargo.toml)
  • [13] JL4WKA5P Implement the Sanakirja concurrency model in a cross-process way
  • [*] AEPEFS7O Write help for each argument

Change contents

  • replacement in pijul/src/repository.rs at line 20
    [4.176][3.0:64]()
    pub const DEFAULT_IGNORE: [&[u8]; 2] = [b".git", b".DS_Store"];
    [4.176]
    [4.21994]
    const DEFAULT_IGNORE: [&[u8]; 2] = [b".git", b".DS_Store"];
    // Static KV map of names for project kinds |-> elements
    // that should go in the `.ignore` file by default.
    const IGNORE_KINDS: &[(&[&str], &[&[u8]])] = &[
    (&["rust"], &[b"/target", b"Cargo.lock"]),
    (&["node", "nodejs"], &[b"node_modules"]),
    (&["lean"], &[b"/build"]),
    ];
  • replacement in pijul/src/repository.rs at line 90
    [4.24299][2.0:83]()
    pub fn init(path: Option<std::path::PathBuf>) -> Result<Self, anyhow::Error> {
    [4.24299]
    [4.24382]
    pub fn init(
    path: Option<std::path::PathBuf>,
    kind: Option<&String>,
    ) -> Result<Self, anyhow::Error> {
  • replacement in pijul/src/repository.rs at line 107
    [4.24728][3.232:275]()
    init_dot_ignore(cur.clone())?;
    [4.24728]
    [3.275]
    init_dot_ignore(cur.clone(), kind)?;
  • replacement in pijul/src/repository.rs at line 130
    [3.608][3.608:689]()
    fn init_dot_ignore(base_path: std::path::PathBuf) -> Result<(), anyhow::Error> {
    [3.608]
    [3.689]
    fn init_dot_ignore(
    base_path: std::path::PathBuf,
    kind: Option<&String>,
    ) -> Result<(), anyhow::Error> {
  • edit in pijul/src/repository.rs at line 151
    [3.1110]
    [3.1110]
    ignore_specific(&mut dot_ignore, kind)
    }
    /// if `kind` matches any of the known project kinds, add the associated
    /// .ignore entries to the default `.ignore` file.
    fn ignore_specific(
    dot_ignore: &mut std::fs::File,
    kind: Option<&String>,
    ) -> Result<(), anyhow::Error> {
    use std::io::Write;
    if let Some(kind) = kind {
    let entries = IGNORE_KINDS
    .iter()
    .find(|(names, _)| names.iter().any(|x| kind.eq_ignore_ascii_case(x)))
    .into_iter()
    .flat_map(|(_, v)| v.iter());
    for entry in entries {
    dot_ignore.write(entry)?;
    dot_ignore.write(b"\n")?;
    }
    }
  • edit in pijul/src/commands/init.rs at line 13
    [4.136728]
    [15.3123]
    /// Project kind; if Pijul knows about your project kind, the .ignore file will be
    /// populated with a conservative list of commonly ignored entries.
    /// Example: `pijul init --kind=rust`
    #[clap(long = "kind", short = 'k')]
    kind: Option<String>,
  • replacement in pijul/src/commands/init.rs at line 24
    [2.1824][2.1824:1873]()
    let repo = Repository::init(self.path)?;
    [2.1824]
    [4.512]
    let repo = Repository::init(self.path, self.kind.as_ref())?;
  • replacement in pijul/src/commands/clone.rs at line 75
    [4.167][2.2306:2360]()
    let mut repo = Repository::init(Some(path))?;
    [4.167]
    [4.16742]
    let mut repo = Repository::init(Some(path), None)?;