Skip to content

Release/v2.0.1#38

Merged
tamada merged 9 commits into
mainfrom
release/v2.0.1
Jul 18, 2025
Merged

Release/v2.0.1#38
tamada merged 9 commits into
mainfrom
release/v2.0.1

Conversation

@tamada

@tamada tamada commented Jul 18, 2025

Copy link
Copy Markdown
Owner

No description provided.

@tamada tamada added this to the v2.0.0 milestone Jul 18, 2025
@tamada tamada requested a review from Copilot July 18, 2025 04:36
@tamada tamada self-assigned this Jul 18, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements the Release v2.0.1 of the sibling project, performing a major code refactoring to separate concerns between library and CLI functionality. The main changes include restructuring the codebase into a workspace with separate library and CLI packages, modernizing the API design, and updating project configuration.

  • Restructured the project into a Rust workspace with separate lib and cli packages
  • Modernized the API by removing mutable state and improving type safety
  • Updated build system and removed Windows installer configuration

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
wix/main.wxs Removed Windows installer configuration file
src/*.rs Removed original source files (moved to lib/cli structure)
lib/src/lib.rs New library implementation with improved API design
cli/src/*.rs New CLI implementation using the library
Cargo.toml Converted to workspace configuration
build.rs Removed build script (functionality moved to CLI)

Comment thread lib/src/lib.rs
Comment on lines +297 to +298
let mut rng = rand::rng();
let next = rng.random_range(0..dirs.dirs.len()) as usize;

Copilot AI Jul 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rand::rng() function may not exist in rand 0.9.0. Use rand::thread_rng() instead for thread-local random number generation.

Suggested change
let mut rng = rand::rng();
let next = rng.random_range(0..dirs.dirs.len()) as usize;
let mut rng = rand::thread_rng();
let next = rng.gen_range(0..dirs.dirs.len()) as usize;

Copilot uses AI. Check for mistakes.
Comment thread lib/src/lib.rs
Comment on lines +297 to +298
let mut rng = rand::rng();
let next = rng.random_range(0..dirs.dirs.len()) as usize;

Copilot AI Jul 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The random_range method doesn't exist in rand 0.9.0. Use gen_range(0..dirs.dirs.len()) instead.

Suggested change
let mut rng = rand::rng();
let next = rng.random_range(0..dirs.dirs.len()) as usize;
let mut rng = rand::thread_rng();
let next = rng.gen_range(0..dirs.dirs.len());

Copilot uses AI. Check for mistakes.
Comment thread lib/src/lib.rs Outdated
Comment on lines +251 to +260
pub fn build_nexter(nexter_type: NexterType) -> Box<dyn Nexter> {
match nexter_type {
NexterType::First => Box::new(First {}),
NexterType::Last => Box::new(Last {}),
NexterType::Previous => Box::new(Previous {}),
NexterType::Next => Box::new(Next {}),
NexterType::Random => Box::new(Random {}),
NexterType::Keep => Box::new(Keep {}),
}
}

Copilot AI Jul 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build_nexter function duplicates the logic from NexterFactory::build. Consider removing this function and using only the factory method to avoid code duplication.

Suggested change
pub fn build_nexter(nexter_type: NexterType) -> Box<dyn Nexter> {
match nexter_type {
NexterType::First => Box::new(First {}),
NexterType::Last => Box::new(Last {}),
NexterType::Previous => Box::new(Previous {}),
NexterType::Next => Box::new(Next {}),
NexterType::Random => Box::new(Random {}),
NexterType::Keep => Box::new(Keep {}),
}
}
// Removed the `build_nexter` function as its logic is already implemented in `NexterFactory::build`.

Copilot uses AI. Check for mistakes.
Comment thread lib/src/lib.rs
Comment on lines +210 to +218
fn find_current_dir_index(dirs: &[PathBuf]) -> usize {
if let Ok(pwd) = std::env::current_dir() {
let cwd = PathBuf::from(".");
if let Some(pos) = dirs
.iter()
.position(|dir| dir == &cwd || pwd.ends_with(dir))
{
return pos;
}

Copilot AI Jul 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function signature changed from &Vec<PathBuf> to &[PathBuf] which is good, but the function calls std::env::current_dir() on every call. Consider caching this value if the function is called multiple times.

Suggested change
fn find_current_dir_index(dirs: &[PathBuf]) -> usize {
if let Ok(pwd) = std::env::current_dir() {
let cwd = PathBuf::from(".");
if let Some(pos) = dirs
.iter()
.position(|dir| dir == &cwd || pwd.ends_with(dir))
{
return pos;
}
fn find_current_dir_index(dirs: &[PathBuf], current_dir: &PathBuf) -> usize {
let cwd = PathBuf::from(".");
if let Some(pos) = dirs
.iter()
.position(|dir| dir == &cwd || current_dir.ends_with(dir))
{
return pos;

Copilot uses AI. Check for mistakes.
Comment thread cli/src/main.rs
fn perform_impl(
dirs: sibling::Dirs,
nexter: &dyn Nexter,
step: usize,

Copilot AI Jul 18, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The step parameter changed from i32 to usize, but the Nexter trait still expects i32. This type mismatch requires casting and could cause issues with negative values that were previously valid.

Suggested change
step: usize,
step: i32,

Copilot uses AI. Check for mistakes.
@tamada tamada merged commit f9187ef into main Jul 18, 2025
5 of 7 checks passed
@tamada tamada deleted the release/v2.0.1 branch January 26, 2026 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants