mirror of
https://github.com/cheat/cheat.git
synced 2025-09-05 19:42:55 +02:00
refactor(repo): create repo
package
- Refactor `installer.clone` into new `repo.Clone` package and method. - Refactor `sheets.isGitDir` into `repo.GitDir`. Both of these changes read better, and will facilitate cleaner architecture when `--update` is implemented.
This commit is contained in:
@ -1,25 +0,0 @@
|
||||
package installer
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
)
|
||||
|
||||
// clone clones the community cheatsheets
|
||||
func clone(path string) error {
|
||||
|
||||
// clone the community cheatsheets
|
||||
_, err := git.PlainClone(path, false, &git.CloneOptions{
|
||||
URL: "https://github.com/cheat/cheatsheets.git",
|
||||
Depth: 1,
|
||||
Progress: os.Stdout,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to clone cheatsheets: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/cheat/cheat/internal/config"
|
||||
"github.com/cheat/cheat/internal/repo"
|
||||
)
|
||||
|
||||
// Run runs the installer
|
||||
@ -45,7 +46,7 @@ func Run(configs string, confpath string) error {
|
||||
if yes {
|
||||
// clone the community cheatsheets
|
||||
fmt.Printf("Cloning community cheatsheets to %s.\n", community)
|
||||
if err := clone(community); err != nil {
|
||||
if err := repo.Clone(community); err != nil {
|
||||
return fmt.Errorf("failed to clone cheatsheets: %v", err)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user