mirror of
https://github.com/cheat/cheat.git
synced 2026-03-07 03:03:32 +01: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:
25
internal/repo/clone.go
Normal file
25
internal/repo/clone.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package repo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
)
|
||||
|
||||
// Clone clones the repo available at `url`
|
||||
func Clone(url string) error {
|
||||
|
||||
// clone the community cheatsheets
|
||||
_, err := git.PlainClone(url, 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
|
||||
}
|
||||
Reference in New Issue
Block a user