-
Notifications
You must be signed in to change notification settings - Fork 558
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
--skip-git
flag to skip git repository initialization (#3402
) * chore: change scaffold command to use `--path` as app directory When `--path` is specified is used as the final app directory. The blockchain name is used to create a directory by default otherwise (previous behaviour). * feat: add `--skip-git` flag to skip git repository initialization * feat(pkg/xgit): add function to check if a path is a Git repository * chore: update changelog --------- Co-authored-by: Alex Johnson <[email protected]>
- Loading branch information
1 parent
bba9d53
commit 571eb43
Showing
5 changed files
with
96 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,9 @@ import ( | |
) | ||
|
||
var ( | ||
commitMsg = "Initialized with Ignite CLI" | ||
devXAuthor = &object.Signature{ | ||
commitMsg = "Initialized with Ignite CLI" | ||
defaultOpenOpts = git.PlainOpenOptions{DetectDotGit: true} | ||
devXAuthor = &object.Signature{ | ||
Name: "Developer Experience team at Ignite", | ||
Email: "[email protected]", | ||
When: time.Now(), | ||
|
@@ -26,9 +27,7 @@ var ( | |
// InitAndCommit creates a git repo in path if path isn't already inside a git | ||
// repository, then commits path content. | ||
func InitAndCommit(path string) error { | ||
repo, err := git.PlainOpenWithOptions(path, &git.PlainOpenOptions{ | ||
DetectDotGit: true, | ||
}) | ||
repo, err := git.PlainOpenWithOptions(path, &defaultOpenOpts) | ||
if err != nil { | ||
if !errors.Is(err, git.ErrRepositoryNotExists) { | ||
return fmt.Errorf("open git repo %s: %w", path, err) | ||
|
@@ -144,3 +143,14 @@ func Clone(ctx context.Context, urlRef, dir string) error { | |
Hash: *h, | ||
}) | ||
} | ||
|
||
// IsRepository checks if a path contains a Git repository. | ||
func IsRepository(path string) (bool, error) { | ||
if _, err := git.PlainOpenWithOptions(path, &defaultOpenOpts); err != nil { | ||
if errors.Is(err, git.ErrRepositoryNotExists) { | ||
return false, nil | ||
} | ||
return false, err | ||
} | ||
return true, 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
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