feat(rev-parse): add revision parsing command#345
feat(rev-parse): add revision parsing command#345marshawcoco wants to merge 18 commits intoweb3infra-foundation:mainfrom
Conversation
Add bisect module that uses binary search to find the commit that introduced a bug between a known "good" and "bad" state. Features: - bisect start [--bad <rev>] [--good <rev>] - initialize session - bisect bad [<rev>] - mark commit as containing the bug - bisect good [<rev>] - mark commit as working correctly - bisect reset [<rev>] - end session and restore original HEAD - bisect skip [<rev>] - skip untestable commits - bisect log - show current bisect state Also fixes SQLite connection string parsing on Windows by normalizing paths with \?\ prefix. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…arnings - Use restore::restore_to_file in bisect checkout to properly handle LFS pointers - Make restore_to_file public in restore.rs for reuse - Fix clippy manual_strip lint by using strip_prefix instead of slicing - Add #[cfg(unix)] to platform-specific imports to resolve unused warnings - Fix unused variable in bisect_test.rs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add rev-parse with CLI and integration coverage, and include Windows-focused test/runtime fixes needed to keep the command workflow stable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Stabilize Windows CI-related tests by normalizing orchestrator paths, avoiding the unimplemented Windows sandbox, and relaxing symlink-sensitive fixtures. Also fix local MCP DB path setup and test helpers that depend on HOME/USERPROFILE overrides. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cd70d00e88
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
Adds a new rev-parse CLI command to resolve revision specs and print repository paths, integrating it into the command registry and adding integration tests to validate expected behaviors.
Changes:
- Introduce
rev-parsecommand implementation + CLI wiring (--short,--abbrev-ref,--show-toplevel, JSON/machine output). - Add integration tests for the new command and adjust existing commit-producing tests to use
--no-verify. - Improve some platform/path handling (Windows main thread spawn, path display normalization, HOME detection, tempdir-based tests).
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/command/rev_parse.rs |
New rev-parse command implementation and argument parsing. |
src/cli.rs |
Register rev-parse in CLI enum and dispatch. |
src/command/mod.rs |
Export the new rev_parse command module. |
tests/command/rev_parse_test.rs |
New integration tests covering resolve/short/abbrev-ref/show-toplevel/json/machine flows. |
tests/command/mod.rs |
Include the new rev_parse_test module. |
src/main.rs |
Windows-specific main-thread spawn changes before running CLI logic. |
src/internal/tui/diff.rs |
Adjust path display logic with additional normalization for relative rendering. |
src/command/fetch.rs |
Prefer HOME/USERPROFILE env vars when deriving home directory for vault temp dir. |
src/internal/ai/tools/utils.rs |
Make path-validation tests use tempdir() instead of hard-coded /tmp paths. |
src/command/tag.rs |
Update tests to commit with --no-verify. |
tests/command/revert_test.rs |
Update revert tests to commit with no_verify: true. |
tests/command/show_ref_test.rs |
Update commit setup to use no_verify: true. |
Complete rev-parse integration with stable error handling and non-ambiguous short hash resolution, and make Windows task worktrees fall back to copying .libra storage when symlink privileges are unavailable. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ec014ad6c6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Fix the remaining workspace storage helper references, make rev-parse --abbrev-ref HEAD return structured errors on HEAD lookup failures, restore the Windows restricted sandbox default, and update the README command support table. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 13527e2f38
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Use fallible branch lookups in rev-parse abbrev-ref resolution so branch storage failures surface as structured fatal errors, and gate the Windows storage copy helper to Windows and test builds to keep clippy clean. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1bc0f348dc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } | ||
|
|
||
| async fn resolve_abbrev_ref(spec: &str) -> CliResult<String> { | ||
| if spec.eq_ignore_ascii_case("HEAD") { |
There was a problem hiding this comment.
Match
HEAD token using exact case
resolve_abbrev_ref currently uses a case-insensitive check for HEAD, so inputs like libra rev-parse --abbrev-ref head are forced into the HEAD code path and can return the current branch even when a real branch named head exists. Git ref names are case-sensitive and head is a valid branch name, so this can return incorrect results and break scripts that rely on exact symbolic-ref resolution. Compare against "HEAD" exactly and let other casings flow through normal branch lookup.
Useful? React with 👍 / 👎.
|
|
||
| fn ensure_vault_ssh_tmp_dir() -> Result<PathBuf, String> { | ||
| let home = dirs::home_dir().ok_or_else(|| "cannot determine home directory".to_string())?; | ||
| let home = resolve_home_directory()?; |
There was a problem hiding this comment.
Use consistent home path for SSH key GC
This change writes vault SSH temp files under resolve_home_directory() but the cleanup pass still scans dirs::home_dir(), so the two paths can diverge when HOME/USERPROFILE overrides are in effect (common in CI/sandboxed runs). In that case expired decrypted key files in the actual write location are never collected after abnormal exits, leaving sensitive material on disk longer than intended. Reuse the same home-resolution logic in cleanup_expired_vault_ssh_temp_files to keep write and GC directories aligned.
Useful? React with 👍 / 👎.
Use an explicit repo database path for cloud env resolution so local config still loads after tests or callers change the process cwd. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 27d63926d5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if args.show_toplevel { | ||
| let workdir = util::try_working_dir().map_err(map_repo_path_error)?; |
There was a problem hiding this comment.
Reject ignored operands when
--show-toplevel is set
resolve_rev_parse returns immediately for --show-toplevel, so any provided SPEC (and --short) is silently ignored while still exiting successfully. For example, libra rev-parse --show-toplevel --short HEAD prints only the worktree path, which can mislead scripts that expect revision resolution and fail-open on incorrect output. Please make these combinations explicit clap conflicts (or implement multi-output semantics) so incompatible arguments do not get dropped silently.
Useful? React with 👍 / 👎.
Add the missing cfg-gated test imports and align the cloud/config changes with rustfmt so the command_test target builds cleanly in CI. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 54e729a0ec
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if let Some(branch) = Branch::find_branch_result(spec, None) | ||
| .await |
There was a problem hiding this comment.
Normalize full local ref names before branch lookup
--abbrev-ref currently queries Branch::find_branch_result with the raw spec, so an input like refs/heads/main is looked up literally and falls through to not a symbolic ref. Git accepts full local refnames here and resolves them to the short branch name (main), so scripts that pass canonical refs will regress. Strip/normalize the refs/heads/ prefix (and then resolve) before doing the branch lookup.
Useful? React with 👍 / 👎.
| if let Some((remote, branch_name)) = spec.split_once('/') | ||
| && !remote.is_empty() |
There was a problem hiding this comment.
Parse remote names with slashes in --abbrev-ref
The remote-tracking path parser assumes the remote name has no / by using split_once('/'). For remotes like team/upstream, team/upstream/main is misparsed as remote=team and branch=upstream/main, so lookup fails even when team/upstream/main exists. This makes --abbrev-ref incorrect for valid remote names; use a parser that can disambiguate remote/branch boundaries (e.g., try split points or reuse branch search logic that already handles nested remote names).
Useful? React with 👍 / 👎.
Update the D1 global config error assertion to match the current config resolution wrapper while remaining compatible with adjacent connection-style messages. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Build tag command test repositories through the direct add/commit helpers instead of parse_async so the force-tag cases start from a reliably committed repo. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4f33b38bf2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if entry.encrypted { | ||
| let plaintext = decrypt_value(&entry.value, "local") | ||
| .await | ||
| .context(format!("failed to decrypt {vault_key}"))?; | ||
| return Ok(Some(plaintext)); |
There was a problem hiding this comment.
Use explicit-db scope when decrypting local env secrets
resolve_env_for_target now supports LocalIdentityTarget::ExplicitDb, but the encrypted branch still calls decrypt_value(..., "local"), which loads the local unseal key from the current repository context rather than from the explicit DB target. In the cwd-drift scenario this change is meant to support (e.g., cloud env read from another repo DB), encrypted vault.env.* values will be read from the correct DB but fail to decrypt, causing cloud credential resolution to fail despite valid stored secrets. Please thread the explicit target (or repo id) into unseal-key lookup so DB selection and decryption use the same repository scope.
Useful? React with 👍 / 👎.
.claude-ci-test.log
Outdated
Drop the accidentally committed .claude-ci-test.log file so the rev-parse PR only contains source and test changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
rev-parsecommand for parsing and normalizing revision names and repository pathsTest plan
cd70d00cargo +nightly fmt --all --checkcargo clippy --all-targets --all-features -- -D warningscargo test --all -- --test-threads=1🤖 Generated with Claude Code