mirror of
https://github.com/runkids/skillshare.git
synced 2026-11-18 18:04:17 +00:00
fix(git): report unmatched include filters from the sync after a pull
The pull response copied only the sync's warnings, so with unmatched include filters moved to their own field, the Git Sync page stopped saying that a filter selected nothing after its automatic sync. The pull response now carries them and the page shows the same notice as the Sync page.
This commit is contained in:
@@ -677,6 +677,7 @@ type pullResponse struct {
|
||||
DryRun bool `json:"dryRun"`
|
||||
Message string `json:"message,omitempty"`
|
||||
Warnings []string `json:"warnings,omitempty"`
|
||||
Unmatched []unmatchedInclude `json:"unmatched,omitempty"`
|
||||
}
|
||||
|
||||
// handlePull pulls changes and syncs to targets
|
||||
@@ -843,6 +844,7 @@ func (s *Server) handlePull(w http.ResponseWriter, r *http.Request) {
|
||||
} else {
|
||||
resp.SyncResults = out.results
|
||||
resp.Warnings = append(resp.Warnings, out.warnings...)
|
||||
resp.Unmatched = out.unmatched
|
||||
if out.pathOverlap > 0 {
|
||||
resp.Warnings = append(resp.Warnings, fmt.Sprintf("Skill path overlap across %d target(s) — see Health Check for details", out.pathOverlap))
|
||||
}
|
||||
|
||||
@@ -703,6 +703,33 @@ func TestHandlePull_EmptyRemoteReturnsCode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandlePull_ReportsUnmatchedIncludeFromItsSync(t *testing.T) {
|
||||
s, src := newTestServer(t)
|
||||
addSkill(t, src, "alpha")
|
||||
s.cfg.Targets["claude"] = config.TargetConfig{Skills: &config.ResourceTargetConfig{Path: filepath.Join(t.TempDir(), "claude-skills"), Include: []string{"missing"}}}
|
||||
if err := s.cfg.Save(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
initServerGitRepo(t, src)
|
||||
testutil.RunGit(t, src, "add", "-A")
|
||||
testutil.RunGit(t, src, "commit", "-m", "alpha")
|
||||
remote := filepath.Join(t.TempDir(), "remote.git")
|
||||
testutil.RunGit(t, "", "init", "--bare", remote)
|
||||
testutil.RunGit(t, src, "remote", "add", "origin", remote)
|
||||
testutil.RunGit(t, src, "push", "-u", "origin", "HEAD")
|
||||
|
||||
rr := postPull(s, `{"alwaysSync":true}`)
|
||||
var resp struct {
|
||||
Unmatched []unmatchedInclude `json:"unmatched"`
|
||||
}
|
||||
if err := json.Unmarshal(rr.Body.Bytes(), &resp); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if rr.Code != http.StatusOK || len(resp.Unmatched) != 1 || resp.Unmatched[0].Target != "claude" {
|
||||
t.Fatalf("expected the unmatched include for claude, got %d: %s", rr.Code, rr.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandlePull_ReportsExtrasSyncWarnings(t *testing.T) {
|
||||
s, _, remote, _ := setupExtrasScopePull(t)
|
||||
pushRemoteFile(t, remote, "other/readme.md", "# other\n")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { SyncResult } from './sync';
|
||||
import type { SyncResult, UnmatchedInclude } from './sync';
|
||||
|
||||
// Git types
|
||||
export interface GitStatus {
|
||||
@@ -55,6 +55,8 @@ export interface PullResponse {
|
||||
dryRun?: boolean;
|
||||
message?: string;
|
||||
warnings?: string[];
|
||||
/** Targets whose include filter selects no skill, from the sync after the pull */
|
||||
unmatched?: UnmatchedInclude[];
|
||||
}
|
||||
|
||||
export interface GitConflictVersion {
|
||||
|
||||
@@ -50,6 +50,15 @@ describe('updates from another computer', () => {
|
||||
],
|
||||
};
|
||||
|
||||
it('explains an include filter that selects no skill after the pull syncs', async () => {
|
||||
vi.mocked(api.gitStatus).mockResolvedValue({ ...status, hasRemote: true, isDirty: false, files: [], ahead: 1, behind: 1 });
|
||||
vi.mocked(api.pull).mockResolvedValue({ success: true, upToDate: false, commits: [], stats: { filesChanged: 1, insertions: 1, deletions: 0 }, syncResults: [],
|
||||
unmatched: [{ target: 'claude', patterns: ['*review*'], all: true }] });
|
||||
mount();
|
||||
fireEvent.click(await screen.findByRole('button', { name: 'Pull and merge' }));
|
||||
expect(await screen.findByRole('link', { name: 'Edit filter' })).toHaveAttribute('href', '/targets/claude');
|
||||
});
|
||||
|
||||
it('compares conflicts and requires a choice for every file before applying', async () => {
|
||||
vi.mocked(api.gitStatus).mockResolvedValue({ ...status, hasRemote: true, isDirty: false, files: [], ahead: 1, behind: 1 });
|
||||
vi.mocked(api.pull).mockRejectedValueOnce(new ApiError(409, 'conflict', { code: 'pull_conflict', params: conflicts }));
|
||||
|
||||
@@ -14,6 +14,7 @@ import { PageSkeleton } from '../components/Skeleton';
|
||||
import { useToast } from '../components/Toast';
|
||||
import { parseStatusLine } from '../components/git/gitView';
|
||||
import PullConflictDialog from '../components/git/PullConflictDialog';
|
||||
import UnmatchedNotices from '../components/sync/UnmatchedNotices';
|
||||
import type { GitPullConflict, GitPullResolution } from '../api/types/git';
|
||||
import { useAppContext } from '../context/AppContext';
|
||||
import { useT, plural } from '../i18n';
|
||||
@@ -275,6 +276,7 @@ export default function GitSyncPage() {
|
||||
</div>
|
||||
)}
|
||||
{pulled?.warnings?.map((w) => <div key={w} className="ss-note warn"><AlertTriangle size={16} /><span className="flex-1 break-words">{w}</span></div>)}
|
||||
<UnmatchedNotices items={pulled?.unmatched} />
|
||||
</div>
|
||||
|
||||
{!status.isRepo ? (
|
||||
|
||||
Reference in New Issue
Block a user