Add "remote add" command [WIP] - #335
Draft
MarcoSteinacher wants to merge 3 commits into
Draft
MarcoSteinacher wants to merge 3 commits into
MarcoSteinacher wants to merge 3 commits into
Conversation
Assisted-by: OpenAgent/Kimi-K2.6
Assisted-by: OpenAgent/Kimi-K2.6
There was a problem hiding this comment.
Pull request overview
This PR is a WIP step toward porting gt remote add from the existing bash implementation to Rust, adding supporting utilities for user prompting and working-directory remote metadata.
Changes:
- Implemented a first Rust version of
gt remote addusinggit2andgpgme, plus initial unit tests. - Added Rust utilities for
pulled.tsv/pull.argshandling and a reusable yes/no prompt helper. - Wired new modules into the Rust binary and added required Rust dependencies.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 23 comments.
Show a summary per file
| File | Description |
|---|---|
| TASK.md | Adds implementation checklist for the Rust remote add port. |
| src/utils.rs | Adds interactive yes/no prompting utilities and related tests. |
| src/pulled-utils.rs | Introduces Rust helpers for pulled.tsv and pull.args I/O. |
| src/main.rs | Registers new pulled_utils and utils modules. |
| src/commands/remote/add.rs | Implements gt remote add in Rust (git remote init/fetch + GPG key import) and adds tests. |
| Cargo.toml | Adds git2, gpgme, and tempfile dependencies. |
| Cargo.lock | Updates lockfile for new dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+7
to
+10
| 1. Read the current bash implementation in function `gt_remote_add()` in `src/gt-remote.sh` | ||
| 3. Implement the remote add in rust in `src/commands/remote/add.rs`. | ||
| 4. Write tests for the command in the same file. | ||
| 5. Verify that the code compiles, passes the linter and formatter, and that all tests pass. |
Comment on lines
+38
to
+48
| /// Like `ask_yes_no`, but repeats until the user gives a clear yes or no answer. | ||
| pub fn ask_yes_no_loop(prompt: &str) -> io::Result<bool> { | ||
| loop { | ||
| let answer = ask_yes_no(prompt)?; | ||
| // ask_yes_no already returns false for anything except y/yes. | ||
| // To mirror bash behavior of warning on unknown input, we'd need | ||
| // to know if the input was blank vs unknown. For simplicity we | ||
| // treat all non-y/yes as "no". | ||
| return Ok(answer); | ||
| } | ||
| } |
Comment on lines
+22
to
+23
| /// Overload that accepts any reader, used for testability. | ||
| pub fn ask_yes_no_with_reader<R, W>(prompt: &str, reader: &mut R, writer: &mut W) -> io::Result<bool> |
Comment on lines
+50
to
+55
| #[derive(Debug)] | ||
| pub enum GtError { | ||
| Io(io::Error), | ||
| Validation(String), | ||
| } | ||
|
|
Comment on lines
+1
to
+3
| #![allow(dead_code)] | ||
|
|
||
| use std::fs::{self, File}; |
Comment on lines
+493
to
+496
| working_directory_arg: WorkingDirectoryArg { | ||
| working_directory: project.to_path_buf(), | ||
| }, | ||
| }; |
Comment on lines
+508
to
+512
| let tmp = TempDir::new().unwrap(); | ||
| let project = tmp.path().join("project"); | ||
| fs::create_dir(&project).unwrap(); | ||
| env::set_current_dir(&project).unwrap(); | ||
|
|
Comment on lines
+525
to
+528
| working_directory_arg: WorkingDirectoryArg { | ||
| working_directory: project.to_path_buf(), | ||
| }, | ||
| }; |
Comment on lines
+541
to
+549
| // Create a bare repo with a .gt directory in its default branch | ||
| { | ||
| let origin = git2::Repository::init_bare(&bare).unwrap(); | ||
| let sig = git2::Signature::now("Test", "test@example.com").unwrap(); | ||
| let tree_id = { | ||
| let mut index = origin.index().unwrap(); | ||
| index.write_tree().unwrap() | ||
| }; | ||
| let tree = origin.find_tree(tree_id).unwrap(); |
| Ok(()) | ||
| } | ||
|
|
||
| fn validate_remote_name(name: &String) -> Result<(), AddError> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I confirm that I have read the Contributor Agreement v1.1, agree to be bound on them and confirm that my contribution is compliant.