in internal/commands/create.go [93:121]
func getDescription(description string, log logrus.FieldLogger) (string, error) {
l := log.WithFields(logrus.Fields{
"description": description,
})
if description == "" || strings.Contains(strings.TrimSpace(description), " ") {
return description, nil
}
baseDir, err := os.Getwd()
if err != nil {
l.WithError(err).Warn("failed to get working directory, using string value for --description")
return description, nil
}
filePath, err := securejoin.SecureJoin(baseDir, description)
if err != nil {
l.WithError(err).Warn("failed to resolve filepath, using string value for --description")
return description, nil
}
content, err := os.ReadFile(filepath.Clean(filePath))
if errors.Is(err, os.ErrNotExist) {
l.WithError(err).Warn("file does not exist, using string value for --description")
return description, nil
}
return string(content), err
}