]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm/sync_sync.go
changes: refactor into separate function and add basic tests
[safcm/safcm.git] / cmd / safcm / sync_sync.go
index e84b7f416c07b84df027f017c826d8b381324d4a..f8aeea2517031c69f214f04d8b13268f1f90ab3c 100644 (file)
@@ -44,26 +44,9 @@ func (s *Sync) hostSync(conn *rpc.Conn, detectedGroups []string) error {
        }
 
        // Display changes
-       var changes []string
-       if len(resp.FileChanges) > 0 {
-               changes = append(changes,
-                       s.formatFileChanges(resp.FileChanges))
-       }
-       if len(resp.PackageChanges) > 0 {
-               changes = append(changes,
-                       s.formatPackageChanges(resp.PackageChanges))
-       }
-       if len(resp.ServiceChanges) > 0 {
-               changes = append(changes,
-                       s.formatServiceChanges(resp.ServiceChanges))
-       }
-       if len(resp.CommandChanges) > 0 {
-               changes = append(changes,
-                       s.formatCommandChanges(resp.CommandChanges))
-       }
-       if len(changes) > 0 {
-               s.logf(safcm.LogInfo, true, "%s",
-                       "\n"+strings.Join(changes, "\n"))
+       changes := s.formatChanges(resp)
+       if changes != "" {
+               s.logf(safcm.LogInfo, true, "%s", changes)
        }
 
        if resp.Error != "" {