-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check if LICENSE exists. #4
base: main
Are you sure you want to change the base?
Conversation
harjyotbagga seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
@@ -41,6 +41,7 @@ type License struct { | |||
func init() { | |||
// Allows a user to not use a license. | |||
Licenses["none"] = License{"None", []string{"none", "false"}, "", ""} | |||
Licenses["empty"] = License{"Empty", []string{"empty", "blank"}, "", ""} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New License type. Also set as the default type.
None License type used to omit License creation.
// If user didn't set any license, use none by default | ||
return Licenses["none"] | ||
// If user didn't set any license, use empty by default | ||
return Licenses["empty"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed Default License type.
if info.IsDir() && filepath.Ext(path) != ".txt" && filepath.Ext(path) != ".md" && filepath.Ext(path) != "" { | ||
return nil | ||
} | ||
reg := regexp.MustCompile(`(?i).*license\.?.*`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used Regex to find License in the project directory.
Regex: Should contain the word license and should not have an extension / should be a .txt or .md
for _, license := range licensesExist { | ||
fmt.Printf(" %s\n", license) | ||
} | ||
fmt.Print("Would you like still to add a license? [Y/n] ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirms to add a LICENSE if one exists.
} | ||
} | ||
if licenseFound { | ||
fmt.Print("LICENSE exists. Would you like to overwrite it? [Y/n] ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ask user to overwrite the LICENSE file if exists.
@@ -50,7 +50,7 @@ func init() { | |||
cobra.CheckErr(viper.BindPFlag("author", rootCmd.PersistentFlags().Lookup("author"))) | |||
cobra.CheckErr(viper.BindPFlag("useViper", rootCmd.PersistentFlags().Lookup("viper"))) | |||
viper.SetDefault("author", "NAME HERE <EMAIL ADDRESS>") | |||
viper.SetDefault("license", "none") | |||
viper.SetDefault("license", "empty") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default License changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes proposed.
@johnSchnake please have a look.
LGTM; built locally and overwrites it when I say 'y', doesn't otherwise. Going to ping someone else for final merging only because of the change of default license; being new to the project I want to be extra cautious about that. @jpmcb Can you confirm if changing the default license to empty is appropriate? E.g. default to leaving the license files alone. Maybe a nit would be naming; would ignore or something else be more appropriate? Functionality here seems fine though. |
I was thinking on similar lines, but as far I remember I came across an issue in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great! Thanks for bringing this feature over so quickly.
We still need to tag this repo so that downstream users can consume it. After that happens, we can start to talk about bringing in features, etc. Blocking on this PR review for now until we go ahead with that.
Sure. Whenever that's done, we can add this feature. |
Heyy, since it's been more than I month. I just wanted to check upon this PR. Is there anything to be done from my end? Or what is the plan that we are looking at ahead? |
This PR is being marked as stale due to a long period of inactivity |
@harjyotbagga - my apologies, it's been a crazy summer here and I haven't had alot of time to dedicate into cobra. We'll get this in soon - this is a great feature add and thank you for your patience! |
Thank you so much for the reply! Super happy to contribute. Please let me know if there are any changes to be done from my end! |
This PR is being marked as stale due to a long period of inactivity |
This PR is being marked as stale due to a long period of inactivity |
@jpmcb Is there anything to be done from my end? |
This PR is being marked as stale due to a long period of inactivity |
This PR is being marked as stale due to a long period of inactivity |
This PR is being marked as stale due to a long period of inactivity |
In continuation to PR #1605
Signed off by: Harjyot Bagga [email protected]
PR to resolve Issue #39
Commands:
To create a project with no LICENSE:
cobra init proj-name -l none
In case of existing LICENSE:
Post Checks: