summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2023-04-08 19:41:37 +0200
committerJustin Wernick <justin@worthe-it.co.za>2023-04-08 19:41:37 +0200
commitff5e3b4dd718e622d81e02c50786c2ec3d5437ae (patch)
tree9de8bebab5d9d5875744d51f3176d9301fb68007
parentc21d81998d3cf573a4b0333f81c22494906cb111 (diff)
Fill in test for updating description on existing repo
This also isn't implemented yet. Naughty naughty.
-rw-r--r--readme.org2
-rw-r--r--src/git.rs4
-rw-r--r--src/lib.rs7
-rw-r--r--src/parser.rs7
-rw-r--r--tests/cli.rs26
5 files changed, 46 insertions, 0 deletions
diff --git a/readme.org b/readme.org
index 0ee646c..df2bb82 100644
--- a/readme.org
+++ b/readme.org
@@ -40,6 +40,8 @@ Pijul.
- [ ] init new repo
- [ ] change an existing repo
- [ ] set the main branch of a repo
+- [ ] Change ~git-init~ name to just be ~init~, with the ~git~ part being a VCS
+ option.
- [ ] help docs on all the commands
** Post-MVP
diff --git a/src/git.rs b/src/git.rs
index 82f32dd..0ef9a42 100644
--- a/src/git.rs
+++ b/src/git.rs
@@ -170,6 +170,10 @@ pub fn list() -> Result<Vec<RepoMetadata>, ShackleError> {
Ok(results)
}
+pub fn set_description(_directory: &PathBuf, _description: &str) -> Result<(), ShackleError> {
+ todo!()
+}
+
pub fn upload_pack(upload_pack_args: &GitUploadPackArgs) -> Result<(), ShackleError> {
if !is_valid_git_repo_path(&upload_pack_args.directory)? {
return Err(ShackleError::InvalidDirectory);
diff --git a/src/lib.rs b/src/lib.rs
index 7d4d2df..60c5df5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -26,6 +26,13 @@ pub fn run_command(user_input: String) -> Result<ControlFlow<(), ()>, ShackleErr
println!("{table}");
}
+ Ok(ShackleCommand::SetDescription(SetDescriptionArgs {
+ directory,
+ description,
+ })) => {
+ git::set_description(&directory, &description)?;
+ println!("Successfully updated description");
+ }
Ok(ShackleCommand::GitInit(GitInitArgs {
repo_name,
group,
diff --git a/src/parser.rs b/src/parser.rs
index 5295483..fd8ab75 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -13,12 +13,19 @@ pub enum ShackleCommand {
Exit,
/// List all repositories available
List,
+ SetDescription(SetDescriptionArgs),
GitInit(GitInitArgs),
GitUploadPack(GitUploadPackArgs),
GitReceivePack(GitReceivePackArgs),
}
#[derive(Parser, Clone, Debug, PartialEq, Eq)]
+pub struct SetDescriptionArgs {
+ pub directory: PathBuf,
+ pub description: String,
+}
+
+#[derive(Parser, Clone, Debug, PartialEq, Eq)]
pub struct GitInitArgs {
#[arg(long)]
pub group: Option<String>,
diff --git a/tests/cli.rs b/tests/cli.rs
index dfbb915..56461ad 100644
--- a/tests/cli.rs
+++ b/tests/cli.rs
@@ -322,3 +322,29 @@ fn can_set_the_description_on_a_repo_during_init() -> Result<()> {
Ok(())
}
+
+#[test]
+fn can_change_the_description_on_a_repo() -> Result<()> {
+ let mut c = spawn_interactive_process()?;
+ let user = get_username().unwrap();
+ let repo_name = "my-personal-repo";
+ let description = "A cool repo that does cool things";
+ c.p.send_line(&format!("git-init {repo_name}"))?;
+ c.p.exp_string(&format!(
+ "Successfully created \"git/{user}/{repo_name}.git\"",
+ ))?;
+ c.p.send_line(&format!(
+ "set-description \"git/{user}/{repo_name}.git\" \"{description}\""
+ ))?;
+ c.p.exp_string("Successfully updated description")?;
+ expect_prompt(&mut c.p)?;
+ expect_list_table(
+ &mut c,
+ &[(
+ format!("git/{user}/{repo_name}.git"),
+ description.to_owned(),
+ )],
+ )?;
+
+ Ok(())
+}