|
|
@@ -152,7 +152,7 @@ func InvokeEditor(path string) error {
|
|
|
// after any modifications made by the editFunc callback and any encountered
|
|
|
// errors.
|
|
|
//
|
|
|
-// Note: A pre-built editor function is provided. See InvokeEditor for more.
|
|
|
+// Note: A pre-built editor callback is provided. See InvokeEditor for more.
|
|
|
func EditTemplate(t Template, editFunc func(path string) error) (data []string, err error) {
|
|
|
// note: wraps writeText
|
|
|
|
|
|
@@ -247,15 +247,18 @@ func IsIssueCollection(path string) bool {
|
|
|
}
|
|
|
|
|
|
// Writes a issue to disk
|
|
|
-func WriteIssue(issue Issue, ignoreExisting bool) (success bool, err error) {
|
|
|
- if IsIssue(issue.Path) && !ignoreExisting {
|
|
|
+func WriteIssue(issue Issue, overwrite bool) (success bool, err error) {
|
|
|
+ if IsIssue(issue.Path) && !overwrite {
|
|
|
return false, errors.New("path exists")
|
|
|
}
|
|
|
|
|
|
// make base directory (effectively, the title)
|
|
|
err = os.Mkdir(issue.Path, 0755)
|
|
|
- if err != nil {
|
|
|
+
|
|
|
+ if err != nil && !overwrite {
|
|
|
return false, err
|
|
|
+ } else {
|
|
|
+ err = nil
|
|
|
}
|
|
|
|
|
|
// Write Fields
|
|
|
@@ -273,8 +276,8 @@ func WriteIssue(issue Issue, ignoreExisting bool) (success bool, err error) {
|
|
|
// Write Tags
|
|
|
if len(issue.Tags.Path) > 0 { // skip tags with no path init
|
|
|
err = os.Mkdir(filepath.Join(issue.Path, issue.Tags.Path), 0755)
|
|
|
- if err != nil {
|
|
|
- return false, err // test by overwrite path
|
|
|
+ if err != nil && !overwrite {
|
|
|
+ return false, err
|
|
|
}
|
|
|
for _, field := range issue.Tags.Fields {
|
|
|
if len(field.Path) > 0 { // skip empty paths
|
|
|
@@ -288,10 +291,10 @@ func WriteIssue(issue Issue, ignoreExisting bool) (success bool, err error) {
|
|
|
}
|
|
|
|
|
|
// Write Blockedby
|
|
|
- if len(issue.Tags.Path) > 0 { // skip blockedby with no path init
|
|
|
+ if len(issue.Blockedby.Path) > 0 { // skip blockedby with no path init
|
|
|
err = os.Mkdir(filepath.Join(issue.Path, issue.Blockedby.Path), 0755)
|
|
|
- if err != nil {
|
|
|
- return false, err // test by overwrite path
|
|
|
+ if err != nil && !overwrite {
|
|
|
+ return false, err
|
|
|
}
|
|
|
for _, field := range issue.Blockedby.Fields {
|
|
|
if len(field.Path) > 0 { // skip empty paths
|
|
|
@@ -302,6 +305,9 @@ func WriteIssue(issue Issue, ignoreExisting bool) (success bool, err error) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if err != nil && !overwrite {
|
|
|
+ return false, err
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return true, nil
|