Skip to content

Sync status flag stuck on 'syncing' when repo has no changes #57

Description

@chubes4

Summary

When RepoSync::sync() finds the remote SHA unchanged (old_sha === $new_sha), it returns early before calling update_sync_status(). Because the method sets the status to 'syncing' at the top of every run (line 42), a project whose docs are already up to date gets permanently left in the 'syncing' state in term meta, even though the sync completed successfully with zero errors.

Impact

  • Cosmetic but misleading: the admin Projects column and RepositoryFields/ProjectColumns display "syncing" indefinitely for healthy, up-to-date projects.
  • Anything reading project_sync_status to gate behavior (health checks, dashboards) sees a false in-progress state.
  • Observed on chubes.net after repointing several projects to renamed GitHub repos: every wp docsync docs sync <id> returned Success / 0 errors, but 5 of 6 terms stayed at project_sync_status = syncing.

Root cause

inc/Sync/RepoSync.php, sync():

$this->update_sync_status( $term_id, 'syncing' ); // line 42
...
if ( $old_sha === $new_sha ) {
    $result['success'] = true;
    $result['error'] = 'No changes detected';
    return $result;                               // line 94 — returns WITHOUT setting 'success'
}

The success path at the bottom (line 115) is only reached when there are actual changes to apply. The no-changes short-circuit skips it.

Fix

Set the status to 'success' on the no-changes early return before returning:

if ( $old_sha === $new_sha ) {
    $result['success'] = true;
    $result['error'] = 'No changes detected';
    $this->update_sync_status( $term_id, 'success' );
    return $result;
}

This also clears any stale project_sync_error via the existing update_sync_status() success branch.

Repro

  1. Sync a project once so project_last_sync_sha is stored.
  2. Sync it again with no upstream commits (wp docsync docs sync <term_id>).
  3. Observe wp term meta get <term_id> project_sync_statussyncing (expected: success).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions