Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cnpryer/huak
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.0.12
Choose a base ref
...
head repository: cnpryer/huak
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.0.13
Choose a head ref
  • 5 commits
  • 10 files changed
  • 2 contributors

Commits on Mar 28, 2023

  1. Bump clap from 4.1.9 to 4.1.14 (#520)

    Bumps [clap](https://github.com/clap-rs/clap) from 4.1.9 to 4.1.14.
    - [Release notes](https://github.com/clap-rs/clap/releases)
    - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
    - [Commits](clap-rs/clap@v4.1.9...v4.1.14)
    
    ---
    updated-dependencies:
    - dependency-name: clap
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Mar 28, 2023
    Copy the full SHA
    1e39863 View commit details
  2. Update user_guide.md (#521)

    * Update user_guide.md
    
    * Update user_guide.md
    cnpryer authored Mar 28, 2023
    Copy the full SHA
    5df682a View commit details
  3. Copy the full SHA
    a736451 View commit details
  4. Copy the full SHA
    1fa03d1 View commit details
  5. Bump to v0.0.13 (#525)

    cnpryer authored Mar 28, 2023
    Copy the full SHA
    b622298 View commit details
Showing with 287 additions and 378 deletions.
  1. +19 −49 Cargo.lock
  2. +2 −2 Cargo.toml
  3. +7 −6 docs/user_guide.md
  4. +1 −1 pyproject.toml
  5. +14 −10 src/bin/huak/cli.rs
  6. +20 −18 src/huak/fs.rs
  7. +4 −4 src/huak/git.rs
  8. +33 −33 src/huak/lib.rs
  9. +169 −234 src/huak/ops.rs
  10. +18 −21 src/huak/sys.rs
68 changes: 19 additions & 49 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "huak"
version = "0.0.12"
version = "0.0.13"
edition = "2021"
license = "MIT"
description = "A Python package manager written in Rust inspired by Cargo."
@@ -18,7 +18,7 @@ path = "./src/huak/lib.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4.1.8", features = ["cargo", "derive"] }
clap = { version = "4.1.14", features = ["cargo", "derive"] }
clap_complete = "4.1.5"
colored = "2.0.0"
git2 = "0.16.1"
13 changes: 7 additions & 6 deletions docs/user_guide.md
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@ You can also assign dependencies to a group using `--group`.

### Install dependencies listed in the pyproject.toml

Use the `install` command to install all of the project's dependencies.
Use the `install` command to install the project's dependencies.

```
my-project on  master [?] is 📦 v0.0.1 via 🐍 v3.11.0
@@ -189,18 +189,19 @@ my-project on  master [?] is 📦 v0.0.1 via 🐍 v3.11.0

### Publish to PyPI

If you're building a Python package you'd like to share, use `huak publish` to build and publish the project to [PyPI](https://pypi.org).
If you're building a Python package you'd like to share, use `huak build` and `huak publish` to build and publish the project to [PyPI](https://pypi.org).

```
my-project on  master [?] is 📦 v0.0.1 via 🐍 v3.11.0
❯ huak build
my-project on  master [?] is 📦 v0.0.1 via 🐍 v3.11.0
❯ huak publish
```

If you just want to build the project use the `build` command.

### Cleaning up

Use `huak clean` to clean up the dist/ directory.
Use `huak clean` to clean out the dist/ directory.

```
my-project on  master [?] is 📦 v0.0.1 via 🐍 v3.11.0 took 26s
@@ -237,4 +238,4 @@ Any bugs or suggestions can be submitted as issues [here](https://github.com/cnp
my-project on  master [?] is 📦 v0.0.1 via 🐍 v3.11.0
❯ huak --version
huak 0.0.10-alpha.6
```
```
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "huak"
version = "0.0.12"
version = "0.0.13"
description = "A Python package manager written in Rust inspired by Cargo."
authors = [
{email = "cnpryer@gmail.com"},
24 changes: 14 additions & 10 deletions src/bin/huak/cli.rs
Original file line number Diff line number Diff line change
@@ -196,9 +196,9 @@ impl Cli {
args: trailing,
include_types: false,
});
if let Some(it) = operation_config.lint_options.as_mut() {
if let Some(a) = it.args.as_mut() {
a.push("--fix".to_string());
if let Some(options) = operation_config.lint_options.as_mut() {
if let Some(args) = options.args.as_mut() {
args.push("--fix".to_string());
}
}
fix(operation_config)
@@ -207,11 +207,13 @@ impl Cli {
operation_config.format_options =
Some(FormatOptions { args: trailing });
if check {
if let Some(it) = operation_config.format_options.as_mut() {
if let Some(a) = it.args.as_mut() {
a.push("--check".to_string());
if let Some(options) =
operation_config.format_options.as_mut()
{
if let Some(args) = options.args.as_mut() {
args.push("--check".to_string());
} else {
it.args = Some(vec!["--check".to_string()]);
options.args = Some(vec!["--check".to_string()]);
}
}
}
@@ -238,9 +240,11 @@ impl Cli {
include_types: !no_types,
});
if fix {
if let Some(it) = operation_config.lint_options.as_mut() {
if let Some(a) = it.args.as_mut() {
a.push("--fix".to_string());
if let Some(options) =
operation_config.lint_options.as_mut()
{
if let Some(args) = options.args.as_mut() {
args.push("--fix".to_string());
}
}
}
38 changes: 20 additions & 18 deletions src/huak/fs.rs
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ pub fn copy_dir<T: AsRef<Path>>(from: T, to: T) -> HuakResult<()> {
Ok(())
}

/// Get an iterator over all paths found in each directory.
pub fn flatten_directories(
directories: impl IntoIterator<Item = PathBuf>,
) -> impl Iterator<Item = PathBuf> {
@@ -54,11 +55,10 @@ pub fn flatten_directories(
/// Search for the path to a target file from a given directory's path and the file_name.
/// The search is executed with the following steps:
/// 1. Get all sub-directories.
/// 2. Search all sub-directories one level for `file_name`.
/// 3. If `file_name` is found, return its path.
/// 4. Else step one level up from its parent's path and decrement the
/// recursion limit.
pub fn find_file_bottom_up<T: AsRef<Path>>(
/// 2. Search all sub-directory roots for file_name.
/// 3. If file_name is found, return its path.
/// 4. Else step one directory up until the `last` directory has been searched.
pub fn find_root_file_bottom_up<T: AsRef<Path>>(
file_name: &str,
dir: T,
last: T,
@@ -70,10 +70,10 @@ pub fn find_file_bottom_up<T: AsRef<Path>>(
if dir.join(file_name).exists() {
return Ok(Some(dir.join(file_name)));
}
// Search all sub-directory roots for target_file
// Search all sub-directory roots for target_file.
if let Some(path) = fs::read_dir(dir)?
.filter(|item| item.is_ok())
.map(|item| item.expect("failed to map dir entry").path()) // TODO: Is there better than .expect?
.map(|item| item.expect("failed to map dir entry").path())
.filter(|item| item.is_dir())
.find(|item| item.join(file_name).exists())
{
@@ -84,7 +84,7 @@ pub fn find_file_bottom_up<T: AsRef<Path>>(
}
// If nothing is found from searching the subdirectories then perform the same search from
// the parent directory.
find_file_bottom_up(
find_root_file_bottom_up(
file_name,
dir.parent().ok_or(Error::InternalError(
"failed to establish a parent directory".to_string(),
@@ -93,24 +93,26 @@ pub fn find_file_bottom_up<T: AsRef<Path>>(
)
}

/// Get the last component of a path. For example this function would return
/// "dir" from the following path:
/// /some/path/to/some/dir
pub fn last_path_component(path: impl AsRef<Path>) -> HuakResult<String> {
let path = path.as_ref();
match path
let path = path
.components()
.last()
.ok_or(Error::InternalError(format!(
"failed to parse project name from {}",
"failed to parse path {}",
path.display()
)))?
.as_os_str()
.to_str()
{
Some(it) => Ok(it.to_string()),
None => Err(Error::InternalError(format!(
"failed to parse project name from {}",
.ok_or(Error::InternalError(format!(
"failed to parse path {}",
path.display()
))),
}
)))?
.to_string();
Ok(path)
}

#[cfg(test)]
@@ -130,11 +132,11 @@ mod tests {
}

#[test]
fn test_find_file_bottom_up() {
fn test_find_root_file_bottom_up() {
let tmp = tempdir().unwrap().into_path();
let from = crate::test_resources_dir_path().join("mock-project");
copy_dir(&from, &tmp.join("mock-project")).unwrap();
let res = find_file_bottom_up(
let res = find_root_file_bottom_up(
"pyproject.toml",
tmp.join("mock-project").as_path(),
tmp.as_path(),
8 changes: 4 additions & 4 deletions src/huak/git.rs
Original file line number Diff line number Diff line change
@@ -2,10 +2,10 @@ use crate::{error::HuakResult, Error};
use git2::Repository;
use std::path::Path;

/// Initialize a directory on a local system as a git repository.
pub fn init(path: impl AsRef<Path>) -> HuakResult<()> {
Repository::init(path).map_err(Error::GitError)?;
Ok(())
/// Initialize a directory on a local system as a git repository
/// and return the Repository.
pub fn init(path: impl AsRef<Path>) -> HuakResult<Repository> {
Repository::init(path).map_err(Error::GitError)
}

#[cfg(test)]
Loading