Skip to content

Commit

Permalink
fix: add docs for use_gitignore and lfs and only provide use_gitignor…
Browse files Browse the repository at this point in the history
…e for PathSource (#361)
  • Loading branch information
pavelzw authored Nov 27, 2023
1 parent f052572 commit 7e93f91
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 29 deletions.
17 changes: 11 additions & 6 deletions docs/recipe_file.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,19 @@ source:
git_depth: -1 # Defaults to -1/not shallow
```

The git_url can also be a relative path to the recipe directory.
The `git_url` can also be a relative path to the recipe directory.

```yaml
source:
git_url: ../../bsdiff4/.git
git_rev: 1.1.4
git_depth: -1 # Defaults to -1/not shallow
lfs: true # defaults to false
```

Note: `git_rev` may not be available within commit depth range, consider avoiding use of both simultaneously.
Note: `git_rev` may not be available within commit depth range, consider avoiding use of both simultaneously.

When you want to use git-lfs, you need to set `lfs: true`. This will also pull the lfs files from the repository.

#### Source from hg

Expand Down Expand Up @@ -224,16 +227,18 @@ source is copied to the work directory before building.
```yaml
source:
path: ../src
use_gitignore: false # (defaults to true)
```

If the local path is a git or svn repository, you get the corresponding
environment variables defined in your build environment. The only practical
difference between git_url or hg_url and path as source arguments is that
git_url and hg_url would be clones of a repository, while path would be a copy
difference between `git_url` or `hg_url` and path as source arguments is that
`git_url` and `hg_url` would be clones of a repository, while path would be a copy
of the repository. Using path allows you to build packages with unstaged and
uncommitted changes in the working directory. git_url can build only up to the
uncommitted changes in the working directory. `git_url` can build only up to the
latest commit.

By default, all files in the local path that are ignored by git are also ignored by rattler-build.
You can disable this behavior by setting `use_gitignore` to `false`.

#### Patches

Expand Down
1 change: 0 additions & 1 deletion examples/ros-humble-turtlebot4-msgs/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ source:
git_url: https://github.com/ros2-gbp/turtlebot4-release.git
git_rev: release/humble/turtlebot4_msgs/1.0.3-1
folder: ros-humble-turtlebot4-msgs/src/work
use_gitignore: true

build:
script:
Expand Down
20 changes: 3 additions & 17 deletions src/recipe/parser/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ pub struct GitSource {
folder: Option<PathBuf>,
/// Optionally request the lfs pull in git source
lfs: bool,
/// Whether to use the `.gitignore` file in the source directory, defaults to `false`.
use_gitignore: bool,
}

impl GitSource {
Expand All @@ -122,7 +120,6 @@ impl GitSource {
patches: Vec<PathBuf>,
folder: Option<PathBuf>,
lfs: bool,
use_gitignore: bool,
) -> Self {
Self {
url,
Expand All @@ -131,7 +128,6 @@ impl GitSource {
patches,
folder,
lfs,
use_gitignore,
}
}

Expand Down Expand Up @@ -164,11 +160,6 @@ impl GitSource {
pub const fn lfs(&self) -> bool {
self.lfs
}

/// Whether to use the `.gitignore` file in the source directory. Defaults to `false`.
pub const fn use_gitignore(&self) -> bool {
self.use_gitignore
}
}

impl TryConvertNode<GitSource> for RenderedMappingNode {
Expand All @@ -179,7 +170,6 @@ impl TryConvertNode<GitSource> for RenderedMappingNode {
let mut patches = Vec::new();
let mut folder = None;
let mut lfs = false;
let mut use_gitignore = false;

// TODO: is there a better place for this error?
// raising the error during parsing allows us to suggest fixes in future
Expand Down Expand Up @@ -224,14 +214,11 @@ impl TryConvertNode<GitSource> for RenderedMappingNode {
"lfs" => {
lfs = v.try_convert("lfs")?;
}
"use_gitignore" => {
use_gitignore = v.try_convert("use_gitignore")?;
}
_ => {
return Err(_partialerror!(
*k.span(),
ErrorKind::InvalidField(k.as_str().to_owned().into()),
help = "valid fields for git `source` are `git_url`, `git_rev`, `git_depth`, `patches`, `lfs`, `folder` and `use_gitignore`"
help = "valid fields for git `source` are `git_url`, `git_rev`, `git_depth`, `patches`, `lfs` and `folder`"
))
}
}
Expand All @@ -254,7 +241,6 @@ impl TryConvertNode<GitSource> for RenderedMappingNode {
patches,
folder,
lfs,
use_gitignore,
})
}
}
Expand Down Expand Up @@ -366,7 +352,7 @@ impl TryConvertNode<UrlSource> for RenderedMappingNode {
return Err(_partialerror!(
*key.span(),
ErrorKind::InvalidField(invalid_key.to_owned().into()),
help = "valid fields for URL `source` are `url`, `sha256`, `md5`, `patches`, `file_name`, `folder` and `use_gitignore`"
help = "valid fields for URL `source` are `url`, `sha256`, `md5`, `patches`, `file_name` and `folder`"
))
}
}
Expand Down Expand Up @@ -461,7 +447,7 @@ impl TryConvertNode<PathSource> for RenderedMappingNode {
return Err(_partialerror!(
*key.span(),
ErrorKind::InvalidField(invalid_key.to_string().into()),
help = "valid fields for path `source` are `path`, `patches` and `folder`"
help = "valid fields for path `source` are `path`, `patches`, `folder` and `use_gitignore`"
))
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/source/git_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ mod tests {
vec![],
None,
false,
false,
),
"rattler-build",
),
Expand All @@ -271,7 +270,6 @@ mod tests {
vec![],
None,
false,
false,
),
"rattler-build",
),
Expand All @@ -287,7 +285,6 @@ mod tests {
vec![],
None,
false,
false,
),
"rattler-build",
),
Expand All @@ -299,7 +296,6 @@ mod tests {
vec![],
None,
false,
false,
),
"rattler-build",
),
Expand Down
2 changes: 1 addition & 1 deletion src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub async fn fetch_sources(
work_dir.to_path_buf()
};
crate::source::copy_dir::CopyDir::new(&result, &dest_dir)
.use_gitignore(src.use_gitignore())
.use_gitignore(false)
.run()?;
if !src.patches().is_empty() {
patch::apply_patches(src.patches(), work_dir, recipe_dir)?;
Expand Down

0 comments on commit 7e93f91

Please sign in to comment.