Skip to content

Commit ef0de43

Browse files
leifericfclaude
andcommitted
fix(p4): sync! applies the same exclude policy as clone!
clone! built its clj-p4.api/clone! request with :exclude derived from resources/p4-excludes.edn, but sync! never assembled the exclude vector — so any changelist that added a file type the user had excluded at clone time would silently get pulled in on the next sync, polluting the history with binary noise the policy meant to drop. sync! now calls (compile-excludes {}) the same way clone! does and forwards the result. Single-arg signature is unchanged; opts symmetry with clone! is a separate concern. Stub-based regression in p4_test intercepts api/sync! and asserts the :exclude vector is non-empty. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7962a52 commit ef0de43

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Fixes
6+
7+
- **`noumenon.p4/sync!` applies the same exclude policy as `clone!`**`clone!` filtered binary noise (`*.fbx`, `*.uasset`, etc. from `resources/p4-excludes.edn`) but `sync!` was building its `clj-p4.api/sync!` request without an `:exclude` field, so any new changelist that added an excluded file type would silently include it on the next sync. Sync now computes the same default exclude vector and passes it through, keeping the imported history aligned with the policy across both the initial clone and every subsequent incremental import.
8+
59
## 0.10.3
610

711
### Fixes

src/noumenon/p4.clj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@
106106

107107
(defn sync!
108108
"Bring an existing clj-p4 clone at `repo-path` up to date with Perforce.
109-
Derives the stream from the most recent commit's `git-p4:` trailer."
109+
Derives the stream from the most recent commit's `git-p4:` trailer.
110+
Applies the same default `p4-excludes.edn` policy `clone!` uses, so
111+
files excluded at clone time stay excluded on every subsequent sync."
110112
[repo-path]
111113
(let [stream (-> (last-commit-message repo-path) stream-from-trailer)]
112114
(when-not stream
@@ -117,6 +119,7 @@
117119
(api/sync! {:conn (conn-from-env)
118120
:stream stream
119121
:target (str repo-path)
122+
:exclude (compile-excludes {})
120123
:progress-fn progress-fn})
121124
(log! "clj-p4: sync complete")
122125
true))

test/noumenon/p4_test.clj

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
bits: depot-path detection, clone-path derivation, exclude-defaults
55
loading from `p4-excludes.edn`, and trailer parsing for sync."
66
(:require [clojure.test :refer [deftest is testing]]
7+
[clj-p4.api :as api]
78
[noumenon.p4 :as p4]))
89

910
(deftest depot-path-detection
@@ -38,3 +39,29 @@
3839
;; Doesn't assert true/false — the test environment may or may not have
3940
;; the p4 binary. Just check the call succeeds and returns a boolean.
4041
(is (boolean? (p4/available?))))
42+
43+
(deftest sync-passes-exclude-policy
44+
(testing "sync! computes the same default excludes as clone! and forwards them"
45+
(let [captured (atom nil)]
46+
(with-redefs [;; Stub out the trailer-parse → return a fake stream
47+
p4/depot-path? (fn [_] true)
48+
;; Intercept the underlying clj-p4 call
49+
api/sync! (fn [m] (reset! captured m) {:synced 0})
50+
;; Stub clj-p4.shell.proc/run-checked! so last-commit-message
51+
;; returns a string carrying a git-p4 trailer (so sync!
52+
;; passes its trailer-presence guard).
53+
clj-p4.shell.proc/run-checked!
54+
(fn [_ & _]
55+
{:exit 0
56+
:stdout-bytes (.getBytes (str "subject\n\n"
57+
"[git-p4: depot-paths = "
58+
\" "//stream/main/" \" ": "
59+
"change = 1]")
60+
"UTF-8")
61+
:stderr "" :elapsed-ms 1})]
62+
(p4/sync! "/tmp/fake-repo")
63+
(let [{:keys [exclude]} @captured]
64+
(is (vector? exclude)
65+
"exclude vector should be present, not nil")
66+
(is (pos? (count exclude))
67+
"default p4-excludes.edn should produce at least one pattern"))))))

0 commit comments

Comments
 (0)