-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move rules for initialization to command (#52)
# Changes ## Primary change Move business logic for initializing a meta repo to the init command. ## Supporting changes Build artifacts on CI in GitHub Actions ## Future work the other commands
- Loading branch information
Showing
8 changed files
with
171 additions
and
44 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
package usemetarepo | ||
|
||
import core "github.com/kkrull/marmot/coremetarepo" | ||
import ( | ||
"fmt" | ||
|
||
core "github.com/kkrull/marmot/coremetarepo" | ||
) | ||
|
||
// Initializes a new meta repo where none existed before. | ||
type InitCommand struct { | ||
MetaDataAdmin core.MetaDataAdmin | ||
} | ||
|
||
func (cmd InitCommand) Run(metaRepoPath string) error { | ||
return cmd.MetaDataAdmin.Create(metaRepoPath) | ||
if isMetaRepo, isMetaRepoErr := cmd.MetaDataAdmin.IsMetaRepo(metaRepoPath); isMetaRepoErr != nil { | ||
return fmt.Errorf("%s: unable to check path; %w", metaRepoPath, isMetaRepoErr) | ||
} else if isMetaRepo { | ||
return fmt.Errorf("%s: already a meta repo", metaRepoPath) | ||
} else if createErr := cmd.MetaDataAdmin.Create(metaRepoPath); createErr != nil { | ||
return fmt.Errorf("failed to initialize meta repo; %w", createErr) | ||
} else { | ||
return nil | ||
} | ||
} |
This file contains 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