Skip to content

feat:为fetch、lfs和merge命令补充测试示例 - #1289

Closed
rick-five wants to merge 3 commits into
gitmono-dev:mainfrom
rick-five:#1269修复

Hidden character warning

The head ref may contain hidden characters: "#1269\u4fee\u590d"
Closed

feat:为fetch、lfs和merge命令补充测试示例#1289
rick-five wants to merge 3 commits into
gitmono-dev:mainfrom
rick-five:#1269修复

Conversation

@rick-five

Copy link
Copy Markdown
Contributor

此PR完成了#1269,修复了PR#1279中出现的问题

Signed-off-by: rick-five <165170199+rick-five@users.noreply.github.com>
Signed-off-by: rick-five <165170199+rick-five@users.noreply.github.com>
Signed-off-by: rick-five <165170199+rick-five@users.noreply.github.com>
@vercel

vercel Bot commented Jul 30, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mega ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 30, 2025 11:01am

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds comprehensive test coverage for the fetch, lfs, and merge commands in the Libra version control system. The implementation fixes issues from PR #1279 by correcting command argument passing syntax and string formatting.

Key changes:

  • Added test suites for merge operations including fast-forward merges, remote branch merges, and merging branches without common ancestors
  • Implemented LFS (Large File Storage) tests covering track/untrack functionality and file listing
  • Created fetch tests with timeout handling for invalid remote repositories

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.

File Description
libra/tests/command/merge_test.rs Comprehensive merge command tests with branch creation, switching, and merging scenarios
libra/tests/command/lfs_test.rs LFS functionality tests for file tracking and status management
libra/tests/command/fetch_test.rs Fetch command tests with timeout handling for network operations

let temp_dir = tempfile::tempdir().expect("Failed to create temporary directory");
let temp_path = temp_dir.path();

// 变量可以直接在 `format!` 字符串中使用

Copilot AI Jul 30, 2025

Copy link

Choose a reason for hiding this comment

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

Comment is in Chinese. Consider using English for consistency with the codebase: '// Variables can be used directly in the format! string'

Suggested change
// 变量可以直接在 `format!` 字符串中使用
// Variables can be used directly in the `format!` string

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +10
// 变量可以直接在 `format!` 字符串中使用
// FIX: 更新 println! 格式

Copilot AI Jul 30, 2025

Copy link

Choose a reason for hiding this comment

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

Comment is in Chinese. Consider using English for consistency: '// FIX: Updated println! format'

Suggested change
// 变量可以直接在 `format!` 字符串中使用
// FIX: 更新 println! 格式
// Variables can be directly used in the `format!` string
// FIX: Updated println! format

Copilot uses AI. Check for mistakes.
println!("Temporary directory created at: {temp_path:?}");
assert!(temp_path.is_dir(), "Temporary path is not a valid directory");

// 修改这一行:使用 env!("CARGO_BIN_EXE_libra") 来获取 libra 可执行文件的路径

Copilot AI Jul 30, 2025

Copy link

Choose a reason for hiding this comment

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

Comment is in Chinese. Consider using English for consistency: '// Modified this line: use env!("CARGO_BIN_EXE_libra") to get the libra executable path'

Suggested change
// 修改这一行:使用 env!("CARGO_BIN_EXE_libra") 来获取 libra 可执行文件的路径
// Modify this line: use env!("CARGO_BIN_EXE_libra") to get the path to the libra executable

Copilot uses AI. Check for mistakes.
.current_dir(temp_path)
.arg("init")
.output()
.expect("Failed to execute libra binary"); // 错误信息保持不变,但现在应该能找到文件了

Copilot AI Jul 30, 2025

Copy link

Choose a reason for hiding this comment

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

Comment is in Chinese. Consider using English for consistency: '// Error message unchanged, but should be able to find the file now'

Suggested change
.expect("Failed to execute libra binary"); // 错误信息保持不变,但现在应该能找到文件了
.expect("Failed to execute libra binary"); // Error message unchanged, but the file should now be locatable

Copilot uses AI. Check for mistakes.
Comment on lines +38 to +44
// FIX: 移除 &
Command::new(env!("CARGO_BIN_EXE_libra"))
.current_dir(temp_path)
.args(["branch", "feature"])
.output()
.expect("Failed to create branch");
// FIX: 移除 &

Copilot AI Jul 30, 2025

Copy link

Choose a reason for hiding this comment

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

Comment is in Chinese. Consider using English for consistency: '// FIX: Removed &'

Suggested change
// FIX: 移除 &
Command::new(env!("CARGO_BIN_EXE_libra"))
.current_dir(temp_path)
.args(["branch", "feature"])
.output()
.expect("Failed to create branch");
// FIX: 移除 &
// FIX: Remove &
Command::new(env!("CARGO_BIN_EXE_libra"))
.current_dir(temp_path)
.args(["branch", "feature"])
.output()
.expect("Failed to create branch");
// FIX: Remove &

Copilot uses AI. Check for mistakes.
Comment on lines +153 to +160
// Create and switch to branch2
// FIX: 移除 &
Command::new(env!("CARGO_BIN_EXE_libra"))
.current_dir(temp_path)
.args(["checkout", "-b", "branch2", "HEAD~1"])
.output()
.expect("Failed to create branch");

Copilot AI Jul 30, 2025

Copy link

Choose a reason for hiding this comment

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

Creating branch2 from HEAD~1 may not achieve the intended behavior of having no common ancestor. This creates branch2 from the parent commit of the current HEAD, which would still share history with branch1.

Suggested change
// Create and switch to branch2
// FIX: 移除 &
Command::new(env!("CARGO_BIN_EXE_libra"))
.current_dir(temp_path)
.args(["checkout", "-b", "branch2", "HEAD~1"])
.output()
.expect("Failed to create branch");
// Create and switch to branch2 as an orphan branch
Command::new(env!("CARGO_BIN_EXE_libra"))
.current_dir(temp_path)
.args(["checkout", "--orphan", "branch2"])
.output()
.expect("Failed to create orphan branch");
// Clean the working directory after creating the orphan branch
Command::new(env!("CARGO_BIN_EXE_libra"))
.current_dir(temp_path)
.args(["reset", "--hard"])
.output()
.expect("Failed to clean working directory");

Copilot uses AI. Check for mistakes.
Comment on lines +70 to +72
// Attempt to fetch with 15-second timeout to avoid hanging CI
eprintln!("Attempting 'libra fetch' with 15s timeout...");
let fetch_result = timeout(Duration::from_secs(15), async {

Copilot AI Jul 30, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] A 15-second timeout may be too long for CI environments and could slow down test execution. Consider reducing to 5-10 seconds or making it configurable via environment variable.

Suggested change
// Attempt to fetch with 15-second timeout to avoid hanging CI
eprintln!("Attempting 'libra fetch' with 15s timeout...");
let fetch_result = timeout(Duration::from_secs(15), async {
// Attempt to fetch with a configurable timeout to avoid hanging CI
let timeout_seconds = std::env::var("LIBRA_FETCH_TIMEOUT")
.ok()
.and_then(|val| val.parse::<u64>().ok())
.unwrap_or(10); // Default to 10 seconds if not set or invalid
eprintln!("Attempting 'libra fetch' with {timeout_seconds}s timeout...");
let fetch_result = timeout(Duration::from_secs(timeout_seconds), async {

Copilot uses AI. Check for mistakes.
@genedna genedna added the libra label Jul 30, 2025
@genedna genedna added this to the Decentralized Git milestone Jul 30, 2025
@genedna genedna closed this Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants