2024-12-29 16:46:19 +01:00
|
|
|
package internal
|
2024-12-29 05:49:26 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type LicenseContext struct {
|
|
|
|
AuthorName string
|
|
|
|
AuthorEmail string
|
|
|
|
Year int
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewLicenseContext(authorName string, authorEmail string) (LicenseContext, error) {
|
|
|
|
var err error
|
|
|
|
if authorName == "" {
|
|
|
|
authorName, err = gitUserData("user.name")
|
|
|
|
}
|
|
|
|
if authorEmail == "" {
|
|
|
|
authorEmail, err = gitUserData("user.email")
|
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
return LicenseContext{}, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return LicenseContext{
|
|
|
|
AuthorName: authorName,
|
|
|
|
AuthorEmail: authorEmail,
|
|
|
|
Year: time.Now().Year(),
|
|
|
|
}, nil
|
|
|
|
}
|