-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support using local directory as template (#162)
- Deprecate `--repo` for `--source` - Fix a bug with license when passing `repo|source` flag --------- Closes #161 Signed-off-by: AlexNg <[email protected]>
- Loading branch information
Showing
11 changed files
with
159 additions
and
28 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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package git | ||
|
||
import ( | ||
"net/url" | ||
"os" | ||
|
||
"github.com/caffeine-addictt/waku/internal/log" | ||
) | ||
|
||
type UrlType string | ||
|
||
const ( | ||
GitUrlType UrlType = "git" | ||
PathUrlType UrlType = "path" | ||
BadUrlType UrlType = "bad" | ||
) | ||
|
||
var validSchemas [4]string = [4]string{"http", "https", "git", "ssh"} | ||
|
||
// CheckUrl checks if a given string s is | ||
// a valid git or path url | ||
func CheckUrl(s string) UrlType { | ||
if IsGitUrl(s) { | ||
return GitUrlType | ||
} | ||
|
||
if IsPathUrl(s) { | ||
return PathUrlType | ||
} | ||
|
||
return BadUrlType | ||
} | ||
|
||
// IsPathUrl checks if a given string s is | ||
// a valid fs path | ||
func IsPathUrl(s string) bool { | ||
log.Debugf("checking if %s is a valid path\n", s) | ||
_, err := os.Stat(s) | ||
v := !os.IsNotExist(err) | ||
|
||
if !v { | ||
log.Debugf("%s is not a valid path", s) | ||
} | ||
|
||
return v | ||
} | ||
|
||
// IsGitUrl checks if a given string s is | ||
// a valid Git url | ||
func IsGitUrl(s string) bool { | ||
log.Debugf("checking if %s is a valid git url\n", s) | ||
parsedUrl, err := url.Parse(s) | ||
if err != nil { | ||
log.Debugf("%s is not a valid url\n", s) | ||
return false | ||
} | ||
|
||
for _, schema := range validSchemas { | ||
if parsedUrl.Scheme == schema { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} |
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,9 +1,10 @@ | ||
package types | ||
|
||
// The <typeStirng> for CLI options | ||
// The <typeString> for CLI options | ||
const ( | ||
PATH string = "<path>" | ||
REPO string = "<repo>" | ||
BRANCH string = "<branch>" | ||
STRING string = "<string>" | ||
PATH string = "<path>" | ||
REPO string = "<repo>" | ||
BRANCH string = "<branch>" | ||
STRING string = "<string>" | ||
REPO_OR_PATH = "<repo|path>" | ||
) |
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,4 +1,4 @@ | ||
package version | ||
|
||
// The current app version | ||
const Version = "0.6.0" | ||
const Version = "0.7.0" |
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