* Fix git config reader can't read values with spaces

Josh Bialkowski created

* Add NewImportWarning for things that aren't exactly errors.
  Use this for unhandled changelog events.
* Add NewExportWarning for things that aren't exactly errors.
  Use this for un-exportable status changes.

Change summary

bridge/core/export.go    | 17 +++++++++++++++++
bridge/core/import.go    | 18 ++++++++++++++++++
repository/config_git.go |  6 +-----
3 files changed, 36 insertions(+), 5 deletions(-)

Detailed changes

bridge/core/export.go 🔗

@@ -29,6 +29,10 @@ const (
 
 	// Error happened during export
 	ExportEventError
+
+	// Something wrong happened during export that is worth notifying to the user
+	// but not severe enough to consider the export a failure.
+	ExportEventWarning
 )
 
 // ExportResult is an event that is emitted during the export process, to
@@ -65,6 +69,11 @@ func (er ExportResult) String() string {
 			return fmt.Sprintf("export error at %s: %s", er.ID, er.Err.Error())
 		}
 		return fmt.Sprintf("export error: %s", er.Err.Error())
+	case ExportEventWarning:
+		if er.ID != "" {
+			return fmt.Sprintf("warning at %s: %s", er.ID, er.Err.Error())
+		}
+		return fmt.Sprintf("warning: %s", er.Err.Error())
 
 	default:
 		panic("unknown export result")
@@ -79,6 +88,14 @@ func NewExportError(err error, id entity.Id) ExportResult {
 	}
 }
 
+func NewExportWarning(err error, id entity.Id) ExportResult {
+	return ExportResult{
+		ID:    id,
+		Err:   err,
+		Event: ExportEventWarning,
+	}
+}
+
 func NewExportNothing(id entity.Id, reason string) ExportResult {
 	return ExportResult{
 		ID:     id,

bridge/core/import.go 🔗

@@ -31,6 +31,10 @@ const (
 
 	// Error happened during import
 	ImportEventError
+
+	// Something wrong happened during import that is worth notifying to the user
+	// but not severe enough to consider the import a failure.
+	ImportEventWarning
 )
 
 // ImportResult is an event that is emitted during the import process, to
@@ -69,6 +73,12 @@ func (er ImportResult) String() string {
 			return fmt.Sprintf("import error at id %s: %s", er.ID, er.Err.Error())
 		}
 		return fmt.Sprintf("import error: %s", er.Err.Error())
+	case ImportEventWarning:
+		if er.ID != "" {
+			return fmt.Sprintf("warning at id %s: %s", er.ID, er.Err.Error())
+		}
+		return fmt.Sprintf("warning: %s", er.Err.Error())
+
 	default:
 		panic("unknown import result")
 	}
@@ -82,6 +92,14 @@ func NewImportError(err error, id entity.Id) ImportResult {
 	}
 }
 
+func NewImportWarning(err error, id entity.Id) ImportResult {
+	return ImportResult{
+		Err:   err,
+		ID:    id,
+		Event: ImportEventWarning,
+	}
+}
+
 func NewImportNothing(id entity.Id, reason string) ImportResult {
 	return ImportResult{
 		ID:     id,

repository/config_git.go 🔗

@@ -66,11 +66,7 @@ func (gc *gitConfig) ReadAll(keyPrefix string) (map[string]string, error) {
 			continue
 		}
 
-		parts := strings.Fields(line)
-		if len(parts) != 2 {
-			return nil, fmt.Errorf("bad git config: %s", line)
-		}
-
+		parts := strings.SplitN(line, " ", 2)
 		result[parts[0]] = parts[1]
 	}