Skip to content

feat(rev): rev-list and rev-parse#349

Merged
genedna merged 20 commits into
libra-tools:mainfrom
marshawcoco:split/rev-commands-clean
Apr 26, 2026
Merged

feat(rev): rev-list and rev-parse#349
genedna merged 20 commits into
libra-tools:mainfrom
marshawcoco:split/rev-commands-clean

Conversation

@marshawcoco

Copy link
Copy Markdown
Contributor

No description provided.

marshawcoco and others added 5 commits April 10, 2026 14:29
Extract the working-directory and tmp-dir fixes into a standalone change so they can land before the rev-parse and rev-list commands.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use USERPROFILE before HOME when resolving the vault SSH temp directory on Windows so MSYS-style HOME paths do not redirect temp key material to the wrong location.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implement revision parsing and reachable-commit listing commands with CLI wiring and integration coverage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Avoid running pre-commit hooks in the tag test helper so the lightweight tag test remains stable in Windows and CI environments.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@marshawcoco
marshawcoco marked this pull request as ready for review April 13, 2026 03:31

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5984887877

ℹ️ 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".

Comment thread src/command/rev_parse.rs Outdated
Keep --abbrev-ref consistent with commit resolution by recognizing refs/remotes/<remote>/<branch> for inputs like origin/main.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5474dc2a50

ℹ️ 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".

Comment thread src/command/rev_parse.rs Outdated
Comment thread src/command/rev_parse.rs Outdated
Make --abbrev-ref treat HEAD case-sensitively and reuse branch search for remote-tracking refs so names like upstream/origin/main resolve correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9a7bb439e4

ℹ️ 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".

Comment thread src/cli.rs
marshawcoco and others added 2 commits April 13, 2026 15:18
Add rev-parse and rev-list to the top-level command list and remove them from the pending commands section so the README matches the shipped CLI.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix rev parsing for multi-segment remote-tracking refs and lock in copy worktree snapshot behavior.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Ivanbeethoven
Ivanbeethoven self-requested a review April 16, 2026 07:18
@Ivanbeethoven

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3e92aae1eb

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/command/rev_parse.rs Outdated
Return the worktree root when rev-parse --show-toplevel is invoked inside .libra, and cover the regression with focused integration tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1c08aa8e62

ℹ️ 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".

Comment thread src/command/rev_parse.rs
Comment thread src/command/rev_parse.rs Outdated
marshawcoco and others added 2 commits April 16, 2026 16:30
Make the patch-applying test model stop only after successful tool results and detect task prompts across the full user history. Include the rustfmt update from the current formatting pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ab2dec640b

ℹ️ 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".

Comment thread src/command/rev_parse.rs Outdated
Detect bare repositories for rev-parse --show-toplevel and add a regression test so bare repos return the expected work tree error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2db040cf1b

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/utils/util.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 07e63e2ed4

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli.rs
Comment thread src/command/rev_parse.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf7634e638

ℹ️ 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".

Comment thread src/command/rev_parse.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 95d2e5745c

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/command/rev_list.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 802d7fdec7

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/command/log.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d19db3beaf

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/command/rev_list.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a2018240ff

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/command/rev_parse.rs
.map(PathBuf::from)
.ok_or_else(CliError::repo_not_found);
}
Ok(workdir)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Canonicalize worktree path for --show-toplevel

When rev-parse --show-toplevel is run from a symlinked worktree path (not from .libra), this branch returns workdir verbatim, so the command emits the symlink alias instead of a canonical repo root. In the same commit, the .libra path branch canonicalizes before returning, so identical repos can produce different top-level paths depending on invocation directory, which can break automation that compares/stores a single normalized root path. Canonicalize the non-storage workdir path before returning to keep output stable.

Useful? React with 👍 / 👎.

@genedna
genedna merged commit 1e60c68 into libra-tools:main Apr 26, 2026
9 checks passed

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

Adds first-class rev-parse / rev-list support to Libra’s CLI, aligning behavior/docs/tests with Git-like revision resolution and commit enumeration (including remote-tracking ref shapes).

Changes:

  • Implement new rev-parse and rev-list commands with human + structured (--json / --machine) output.
  • Extend revision resolution to better handle remote-tracking refs (including multi-segment remotes).
  • Add integration docs/tests and adjust existing log/shortlog behavior/tests to match “newest first” ordering.

Reviewed changes

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

Show a summary per file
File Description
src/command/rev_parse.rs New rev-parse implementation (resolve hashes/refs, --short, --abbrev-ref, --show-toplevel).
src/command/rev_list.rs New rev-list implementation (walk reachable commits and output newest-first + JSON).
src/cli.rs Wires rev-parse / rev-list into the top-level CLI dispatcher.
src/command/mod.rs Exposes new command modules.
src/utils/util.rs Adds remote_tracking_candidates + improves remote-tracking ref resolution paths.
tests/command/rev_parse_test.rs New integration coverage for rev-parse behaviors (short hash, abbrev-ref, show-toplevel, error codes, JSON/machine).
tests/command/rev_list_test.rs New integration coverage for rev-list behaviors (default HEAD, ordering, errors, JSON/machine, quiet).
tests/command/mod.rs Registers the new integration test modules.
src/command/log.rs Clarifies “newest first” sorting comments / minor consistency tweaks.
tests/command/log_test.rs Makes log tests assert expected message ordering more directly.
src/command/shortlog.rs Adjusts commit sorting to “newest first” using committer timestamps.
src/command/tag.rs Updates tag tests to commit with --no-verify.
src/internal/ai/orchestrator/workspace.rs Adds a test ensuring copy-based task worktrees include untracked workspace files.
src/internal/ai/orchestrator/executor.rs Improves mock prompt aggregation / tool-result detection in tests.
docs/commands/rev-parse.md New user documentation for libra rev-parse.
docs/commands/rev-list.md New user documentation for libra rev-list.
docs/commands/README.md Adds rev-parse / rev-list to the commands index.
README.md Advertises new commands and removes them from “not implemented”.

Comment thread src/command/rev_list.rs
Comment on lines +49 to +50
writeln!(writer, "{commit}")
.map_err(|e| CliError::io(format!("failed to write rev-list output: {e}")))?;

Copilot AI Apr 26, 2026

Copy link

Choose a reason for hiding this comment

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

writeln! write failures are mapped via CliError::io(...), which hard-codes StableErrorCode::IoReadFailed. For stdout/stderr writes this should report IoWriteFailed (and ideally treat BrokenPipe as a non-error like Pager does) so the CLI stable error code/category is accurate.

Suggested change
writeln!(writer, "{commit}")
.map_err(|e| CliError::io(format!("failed to write rev-list output: {e}")))?;
if let Err(err) = writeln!(writer, "{commit}") {
if err.kind() == std::io::ErrorKind::BrokenPipe {
return Ok(());
}
return Err(CliError::new(
StableErrorCode::IoWriteFailed,
format!("failed to write rev-list output: {err}"),
));
}

Copilot uses AI. Check for mistakes.
Comment thread src/command/rev_list.rs
Comment on lines +62 to +63
// sort by newest first as per rev-list contract
commits.sort_by_key(|c| std::cmp::Reverse(c.committer.timestamp));

Copilot AI Apr 26, 2026

Copy link

Choose a reason for hiding this comment

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

Sorting only by committer.timestamp can yield non-deterministic output when multiple commits share the same timestamp (Rust’s sort_by_key is unstable for equal keys). Consider adding a deterministic tie-breaker (e.g., (Reverse(timestamp), id)), which also removes the need for timing hacks in tests.

Suggested change
// sort by newest first as per rev-list contract
commits.sort_by_key(|c| std::cmp::Reverse(c.committer.timestamp));
// Sort by newest first as per rev-list contract, and use commit ID as a
// deterministic tie-breaker when multiple commits share the same timestamp.
commits.sort_by(|a, b| {
b.committer
.timestamp
.cmp(&a.committer.timestamp)
.then_with(|| a.id.cmp(&b.id))
});

Copilot uses AI. Check for mistakes.
Comment thread src/command/rev_parse.rs
Comment on lines +68 to +69
writeln!(writer, "{}", result.value)
.map_err(|e| CliError::io(format!("failed to write rev-parse output: {e}")))

Copilot AI Apr 26, 2026

Copy link

Choose a reason for hiding this comment

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

writeln! write failures are mapped via CliError::io(...), which hard-codes StableErrorCode::IoReadFailed. For stdout writes this should use IoWriteFailed (and consider handling BrokenPipe as a graceful early-exit) so error reporting is correct and consistent with other output paths (e.g., Pager).

Suggested change
writeln!(writer, "{}", result.value)
.map_err(|e| CliError::io(format!("failed to write rev-parse output: {e}")))
match writeln!(writer, "{}", result.value) {
Ok(()) => Ok(()),
Err(err) if err.kind() == std::io::ErrorKind::BrokenPipe => Ok(()),
Err(err) => Err(CliError::new(
StableErrorCode::IoWriteFailed,
format!("failed to write rev-parse output: {err}"),
)),
}

Copilot uses AI. Check for mistakes.

let stdout = String::from_utf8_lossy(&output.stdout);
let value = stdout.trim();
assert_eq!(value.len(), 40, "expected full hash, got: {value}");

Copilot AI Apr 26, 2026

Copy link

Choose a reason for hiding this comment

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

This test hard-codes a 40-character hash length, which assumes SHA-1. Since the repo supports multiple hash kinds, derive the expected hex length from the active hash kind (or validate by parsing to ObjectHash) so the test won’t break if defaults/config change.

Suggested change
assert_eq!(value.len(), 40, "expected full hash, got: {value}");
assert!(
matches!(value.len(), 40 | 64),
"expected full hash with a supported hex length, got: {value}"
);

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +12
use std::{fs, thread, time::Duration};

use super::*;

fn create_two_commit_repo_via_cli() -> tempfile::TempDir {
let repo = create_committed_repo_via_cli();

thread::sleep(Duration::from_secs(1));

Copilot AI Apr 26, 2026

Copy link

Choose a reason for hiding this comment

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

Using thread::sleep(Duration::from_secs(1)) to force distinct commit timestamps makes the test slower and still relies on wall-clock behavior. Prefer making rev-list ordering deterministic for equal timestamps (e.g., add a tie-breaker in the sort) so the test can avoid sleeping.

Suggested change
use std::{fs, thread, time::Duration};
use super::*;
fn create_two_commit_repo_via_cli() -> tempfile::TempDir {
let repo = create_committed_repo_via_cli();
thread::sleep(Duration::from_secs(1));
use std::fs;
use super::*;
fn create_two_commit_repo_via_cli() -> tempfile::TempDir {
let repo = create_committed_repo_via_cli();

Copilot uses AI. Check for mistakes.
@marshawcoco
marshawcoco deleted the split/rev-commands-clean branch April 29, 2026 03:20
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.

4 participants