diff --git a/README.md b/README.md index ebb4a56..28ac9b7 100644 --- a/README.md +++ b/README.md @@ -77,14 +77,15 @@ $ go get git@github.com/tamada/rrh.git Usage: rrh [--version] [--help] [] Available commands are: - add add repositories on the local path to RRH - clone run "git clone" and register it to a group + add add repositories on the local path to RRH. + clone run "git clone" and register it to a group. config set/unset and list configuration of RRH. export export RRH database to stdout. - fetch run "git fetch" on the repositories of the given groups - fetch-all run "git fetch" in the all repositories + fetch run "git fetch" on the repositories of the given groups. + fetch-all run "git fetch" in the all repositories. group add/list/update/remove groups. list print managed repositories and their groups. + mv move the repositories from groups to another group. prune prune unnecessary repositories and groups. rm remove given repository from database. status show git status of repositories. diff --git a/add/add_cmd.go b/add/add_cmd.go index 1f0a7d4..e3245b7 100644 --- a/add/add_cmd.go +++ b/add/add_cmd.go @@ -102,5 +102,5 @@ func (add *AddCommand) parse(args []string, config *common.Config) (*addOptions, Synopsis returns the simple help message of the command. */ func (add *AddCommand) Synopsis() string { - return "add repositories on the local path to RRH" + return "add repositories on the local path to RRH." } diff --git a/add/add_test.go b/add/add_test.go index 73cd953..5bbb335 100644 --- a/add/add_test.go +++ b/add/add_test.go @@ -27,7 +27,7 @@ func TestInvalidOptions(t *testing.T) { func TestHelpAndSynopsis(t *testing.T) { var command, _ = AddCommandFactory() - if command.Synopsis() != "add repositories on the local path to RRH" { + if command.Synopsis() != "add repositories on the local path to RRH." { t.Error("synopsis did not match") } if command.Help() != `rrh add [OPTIONS] diff --git a/clone/clone_cmd.go b/clone/clone_cmd.go index 3a30eef..783c8bf 100644 --- a/clone/clone_cmd.go +++ b/clone/clone_cmd.go @@ -45,7 +45,7 @@ ARGUMENTS Synopsis returns the help message of the command. */ func (clone *CloneCommand) Synopsis() string { - return "run \"git clone\" and register it to a group" + return "run \"git clone\" and register it to a group." } func (clone *CloneCommand) printIfVerbose(message string) { diff --git a/clone/clone_test.go b/clone/clone_test.go index b4f3be5..5d7aec6 100644 --- a/clone/clone_test.go +++ b/clone/clone_test.go @@ -164,7 +164,7 @@ ARGUMENTS t.Error("help message did not match") } - if clone.Synopsis() != `run "git clone" and register it to a group` { + if clone.Synopsis() != `run "git clone" and register it to a group.` { t.Error("synopsis did not match") } } diff --git a/common/database.go b/common/database.go index 1aacec6..79fb2f4 100644 --- a/common/database.go +++ b/common/database.go @@ -204,9 +204,7 @@ func (db *Database) UpdateGroup(groupID string, newGroup Group) bool { } for i, group := range db.Groups { if group.Name == groupID { - db.Groups[i].Name = newGroup.Name - db.Groups[i].Description = newGroup.Description - db.Groups[i].OmitList = newGroup.OmitList + db.updateGroupImpl(i, groupID, newGroup) } } sortIfNeeded(db) @@ -214,6 +212,17 @@ func (db *Database) UpdateGroup(groupID string, newGroup Group) bool { return true } +func (db *Database) updateGroupImpl(index int, groupID string, newGroup Group) { + db.Groups[index].Name = newGroup.Name + db.Groups[index].Description = newGroup.Description + db.Groups[index].OmitList = newGroup.OmitList + for i, relation := range db.Relations { + if relation.GroupName == groupID { + db.Relations[i].GroupName = newGroup.Name + } + } +} + /* Relate create the relation between the group and the repository. The group and the repository are specified by the given parameters. diff --git a/fetch/fetch_all_cmd.go b/fetch/fetch_all_cmd.go index dd5a06e..512893d 100644 --- a/fetch/fetch_all_cmd.go +++ b/fetch/fetch_all_cmd.go @@ -104,5 +104,5 @@ func (fetch *FetchAllCommand) parse(args []string) (*FetchOptions, error) { Synopsis returns the help message of the command. */ func (fetch *FetchAllCommand) Synopsis() string { - return "run \"git fetch\" in the all repositories" + return "run \"git fetch\" in the all repositories." } diff --git a/fetch/fetch_cmd.go b/fetch/fetch_cmd.go index d26ff97..6d1ccad 100644 --- a/fetch/fetch_cmd.go +++ b/fetch/fetch_cmd.go @@ -26,7 +26,7 @@ ARGUMENTS } func (fetch *FetchCommand) Synopsis() string { - return "run \"git fetch\" on the given groups" + return "run \"git fetch\" on the given groups." } func (fetch *FetchCommand) Run(args []string) int { diff --git a/move/move_cmd.go b/move/move_cmd.go index 8896b5e..15963f2 100644 --- a/move/move_cmd.go +++ b/move/move_cmd.go @@ -289,5 +289,5 @@ ARGUMENTS Synopsis returns the help message of the command. */ func (mv *MoveCommand) Synopsis() string { - return "move the repositories from groups to another group" + return "move the repositories from groups to another group." } diff --git a/move/move_test.go b/move/move_test.go index b6d35eb..e3d73d0 100644 --- a/move/move_test.go +++ b/move/move_test.go @@ -175,8 +175,8 @@ func TestMergeType(t *testing.T) { func TestSynopsis(t *testing.T) { var mv, _ = MoveCommandFactory() - if mv.Synopsis() != "move the repositories from groups to another group" { - t.Error("Synopsis message is not matched.") + if mv.Synopsis() != "move the repositories from groups to another group." { + t.Error("Synopsis message is not matched") } } @@ -190,6 +190,6 @@ ARGUMENTS FROMS... specifies move from, formatted in , or TO specifies move to, formatted in ` if mv.Help() != helpMessage { - t.Error("Help message is not matched.") + t.Error("Help message is not matched") } }