summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--readme.org8
-rw-r--r--src/git.rs48
2 files changed, 20 insertions, 36 deletions
diff --git a/readme.org b/readme.org
index df2bb82..acaca0c 100644
--- a/readme.org
+++ b/readme.org
@@ -36,12 +36,12 @@ Pijul.
- [X] don't allow this to be a group the user isn't in
- [X] allow pull and push from shared repos
- [X] listing of repos
-- [ ] set repo descriptions
- - [ ] init new repo
- - [ ] change an existing repo
-- [ ] set the main branch of a repo
+- [X] set repo descriptions
+ - [X] init new repo
+ - [X] change an existing repo
- [ ] Change ~git-init~ name to just be ~init~, with the ~git~ part being a VCS
option.
+- [ ] set the main branch of a repo
- [ ] help docs on all the commands
** Post-MVP
diff --git a/src/git.rs b/src/git.rs
index 979e7b9..4b1ec0d 100644
--- a/src/git.rs
+++ b/src/git.rs
@@ -70,44 +70,28 @@ pub fn init(
group: &Option<String>,
description: &Option<String>,
) -> Result<GitInitResult, ShackleError> {
- fn init_group_opts(
- repo_name: &str,
- group: &str,
- ) -> Result<(PathBuf, RepositoryInitOptions), ShackleError> {
- if !verify_user_is_in_group(group) {
- return Err(ShackleError::InvalidGroup);
- }
-
- let path = group_git_dir(group).join(repo_name).with_extension("git");
- let mut init_opts = RepositoryInitOptions::new();
- init_opts
- .bare(true)
- .mode(RepositoryInitMode::SHARED_GROUP)
- .mkdir(true)
- .no_reinit(true);
-
- Ok((path, init_opts))
- }
-
- fn init_personal_opts(
- repo_name: &str,
- ) -> Result<(PathBuf, RepositoryInitOptions), ShackleError> {
- let path = personal_git_dir()?.join(repo_name).with_extension("git");
- let mut init_opts = RepositoryInitOptions::new();
- init_opts.bare(true).mkdir(true).no_reinit(true);
+ let mut init_opts = RepositoryInitOptions::new();
+ init_opts.bare(true).mkdir(true).no_reinit(true);
- Ok((path, init_opts))
- }
+ let path = match group {
+ Some(group) => {
+ if !verify_user_is_in_group(group) {
+ return Err(ShackleError::InvalidGroup);
+ }
- let (path, mut init_opts) = match group {
- Some(group) => init_group_opts(repo_name, group)?,
- None => init_personal_opts(repo_name)?,
+ init_opts.mode(RepositoryInitMode::SHARED_GROUP);
+ group_git_dir(group).join(repo_name).with_extension("git")
+ }
+ None => personal_git_dir()?.join(repo_name).with_extension("git"),
};
+
+ Repository::init_opts(&path, &init_opts)?;
if let Some(description) = description {
- init_opts.description(description);
+ // There is an init option for setting the description but it seems to
+ // just do nothing?
+ set_description(&path, &description)?;
}
- Repository::init_opts(&path, &init_opts)?;
Ok(GitInitResult { path })
}