Skip to content

Fix build failures, config loading, and wire remaining CLI commands#17

Merged
bashandbone merged 5 commits intocli-improvementsfrom
copilot/sub-pr-12-again
Mar 4, 2026
Merged

Fix build failures, config loading, and wire remaining CLI commands#17
bashandbone merged 5 commits intocli-improvementsfrom
copilot/sub-pr-12-again

Conversation

Copy link
Contributor

Copilot AI commented Mar 4, 2026

The codebase had multiple compilation errors and a broken config round-trip that caused all submodule lookups to silently return empty. Most integration tests were failing as a result.

Config loading (root cause of most failures)

SubmoduleEntries serialize/deserialize mismatch: #[derive(Serialize)] emitted struct field names (submodules, sparse_checkouts) while the custom Deserialize treated all map keys as submodule names. Figment's default-merging round-tripped these field names back as phantom submodule entries. Added a custom Serialize impl that emits a flat name → entry map.

.nested() in Figment: Toml::file(path).nested() wrapped TOML section names as Figment profile keys, making every [my-lib] section invisible on extraction. Removed .nested().

Add submodule not cloning

Both gix and git2 add_submodule implementations returned Ok(()) without cloning:

  • gix: only wrote .gitmodules, no clone
  • git2: left partial filesystem state (.git file written, no fetch), causing the CLI fallback to fail on re-entry

Both now return Err(...) to fall through to the git submodule add CLI fallback, which is reliable.

Compilation errors

  • config.rs: missing use serde::de::Deserializer / use serde::ser::SerializeMap
  • options.rs: trimmed used before binding in from_gitmodules() — added let trimmed = options.trim()
  • utilities.rs: lifetime error from borrowing a temporary in get_current_branch(); refactored with an inner helper to eliminate the issue and the duplicated head-reading logic
  • main.rs: duplicate let bindings, missing use clap_complete::generate, bool passed where Option<bool> expected

CLI command fixes

  • Delete / Disable variants were missing their required name field
  • Reset.all: invalid value_hint on a boolean flag (clap panics at runtime)
  • GenerateConfig.from_setup: was required; made Option<String> to support empty-config generation
  • Implemented GenerateConfig and NukeItFromOrbit command handlers (both previously returned a "not yet implemented" error)
  • Fixed /** doc-comment blocks in utilities.rs that Rust was compiling as doctests

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits March 4, 2026 13:20
…ommands

Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 4, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • invalid-host
    • Triggering command: /usr/bin/ssh /usr/bin/ssh -o SendEnv=GIT_PROTOCOL git@invalid-host git-upload-pack &#39;user/repo.git&#39; user.email (dns block)
    • Triggering command: /usr/bin/ssh /usr/bin/ssh -o SendEnv=GIT_PROTOCOL git@invalid-host git-upload-pack &#39;user/repo.git&#39; -b (dns block)
    • Triggering command: /usr/bin/ssh /usr/bin/ssh -o SendEnv=GIT_PROTOCOL git@invalid-host git-upload-pack &#39;user/repo.git&#39; k/submod/submod/-- k/submod/submod/file:///tmp/.tmpCYTCqS/sparse_invalid.git large_repo.git 15uqmp420ibalv4agit stup/toolchains/config p/bin/git git subm�� deinit --all t k/submod/submod/git k/submod/submod/rev-parse nfig/composer/ve--is-inside-work-tree git (dns block)
  • nonexistent.domain.invalid
    • Triggering command: /usr/lib/git-core/git-remote-http /usr/lib/git-core/git-remote-http origin REDACTED git conf�� user.email test@example.com git 1.0b9qk2i.rcgu.ogit 2.0b9qk2i.rcgu.ocheckout de/node/bin/git cargo meta�� --format-version 1 cal/bin/git y.0b9qk2i.rcgu.o/usr/lib/git-core/git l.0b9qk2i.rcgu.opack-objects rgo git (dns block)
    • Triggering command: /usr/lib/git-core/git-remote-http /usr/lib/git-core/git-remote-http origin REDACTED git chec�� -b main k/_temp/ghcca-node/node/bin/git --git-path objects rgo/bin/git git subm�� deinit --all e/git add --name it e/git (dns block)
    • Triggering command: /usr/lib/git-core/git-remote-http /usr/lib/git-core/git-remote-http origin REDACTED id -u f1do24.rcgu.o f1do24.rcgu.o nfig/composer/vendor/bin/git f1do24.rcgu.o f1do24.rcgu.o o git conf�� low always /snap/bin/git k/submod/submod/envsubst o.git k/_temp/ghcca-node/node/bin/git git (dns block)
  • nonexistent.invalid.domain.test
    • Triggering command: /usr/lib/git-core/git-remote-http /usr/lib/git-core/git-remote-http origin REDACTED git comm�� -m Add test content /snap/bin/git /tmp/rustcd2oiy4git sf02Ae/concurrenconfig nfig/composer/veuser.email git conf�� user.name Test User rgo/bin/git /home/REDACTED/worgit config_test.git it git (dns block)
    • Triggering command: /usr/lib/git-core/git-remote-http /usr/lib/git-core/git-remote-http origin REDACTED git add . git tnet/tools/git user.email (dns block)
    • Triggering command: /usr/lib/git-core/git-remote-http /usr/lib/git-core/git-remote-http origin REDACTED git comm�� -m Initial commit ndor/bin/git /tmp/rustcGx54uqgit /home/REDACTED/worconfig /usr/local/bin/guser.email git push�� e/git-submodule origin tnet/tools/git README.md low cal/bin/git git (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Enhance CLI and overhaul fallback trait system Fix build failures, config loading, and wire remaining CLI commands Mar 4, 2026
@bashandbone bashandbone marked this pull request as ready for review March 4, 2026 19:11
Copilot AI review requested due to automatic review settings March 4, 2026 19:11
Copy link
Contributor

Copilot AI left a comment

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 fixes multiple compilation errors and a broken configuration round-trip in the submod CLI tool, and wires up previously stubbed CLI commands (GenerateConfig and NukeItFromOrbit).

The root cause of most integration test failures was a SubmoduleEntries serialize/deserialize mismatch and incorrect use of Figment's .nested() API. Both gix and git2 add_submodule implementations are changed to intentionally return Err to force the existing CLI fallback path.

Changes:

  • src/config.rs: Added custom Serialize impl for SubmoduleEntries (flat name→entry map), removed .nested() from Figment config loading, and added missing serde imports
  • src/commands.rs: Added required name fields to Delete/Disable variants, removed invalid value_hint on Reset.all, changed from_setup from String to Option<String>
  • src/main.rs/src/utilities.rs/src/options.rs/src/git_ops/*.rs: Fixed compilation errors (duplicate bindings, missing imports, lifetime issue, trimmed binding), implemented GenerateConfig and NukeItFromOrbit handlers, and made gix/git2 add_submodule fall through to the CLI

Reviewed changes

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

Show a summary per file
File Description
src/config.rs Custom SubmoduleEntries::Serialize, .nested() removal, added missing use items
src/commands.rs Added name to Delete/Disable, fixed Reset.all, changed from_setup to Option<String>
src/main.rs Removed duplicate bindings and unused imports, added clap_complete::generate, implemented GenerateConfig/NukeItFromOrbit handlers
src/utilities.rs Refactored get_current_branch with inner helper to fix lifetime error; replaced /** doc-comment blocks
src/options.rs Added let trimmed = options.trim() before use in from_gitmodules
src/git_ops/gix_ops.rs add_submodule now returns Err to force CLI fallback
src/git_ops/git2_ops.rs add_submodule now returns Err to force CLI fallback

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +311 to +315
// gix does not support cloning in add_submodule; fall through to git2/CLI.
Err(anyhow::anyhow!(
"gix add_submodule not implemented: use git2 or CLI fallback for '{}'",
opts.name
))
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

The error message "gix add_submodule not implemented: use git2 or CLI fallback for '...'" is an internal implementation detail that will be printed to stderr via the eprintln! in try_with_fallback_mut every time a user runs add. A more user-friendly approach would be to use a sentinel error type (e.g., a specific variant or a recognized message like "not implemented") that try_with_fallback_mut can detect and suppress the stderr log for, since this fallback is always expected — it is not a real failure. Similarly for the git2 error message.

Copilot uses AI. Check for mistakes.
use std::str::FromStr;
use submod::options::SerializableBranch;

use clap_complete::generate;
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

A blank line is missing between the use clap_complete::generate; import and the fn main() definition. In Rust convention and throughout the rest of this file, import blocks are separated from function definitions by a blank line. This is a minor formatting issue but inconsistent with the surrounding code style.

Suggested change
use clap_complete::generate;
use clap_complete::generate;

Copilot uses AI. Check for mistakes.
bashandbone and others added 2 commits March 4, 2026 14:45
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@bashandbone bashandbone merged commit 2b4ce4a into cli-improvements Mar 4, 2026
@bashandbone bashandbone deleted the copilot/sub-pr-12-again branch March 4, 2026 21:09
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