@@ -100,4 +100,88 @@ This is a summarized CLAUDE.md without markers.
100100 expect ( `${ result . stdout } \n${ result . stderr } ` ) . toContain ( 'missing required OMC markers' ) ;
101101 expect ( existsSync ( join ( fixture . projectRoot , '.claude' , 'CLAUDE.md' ) ) ) . toBe ( false ) ;
102102 } ) ;
103+
104+ it ( 'adds a local git exclude block for .omc artifacts while preserving .omc/skills' , ( ) => {
105+ const fixture = createPluginFixture ( `<!-- OMC:START -->
106+ <!-- OMC:VERSION:9.9.9 -->
107+
108+ # Canonical CLAUDE
109+ Use the real docs file.
110+ <!-- OMC:END -->
111+ ` ) ;
112+
113+ const gitInit = spawnSync ( 'git' , [ 'init' ] , {
114+ cwd : fixture . projectRoot ,
115+ env : {
116+ ...process . env ,
117+ HOME : fixture . homeRoot ,
118+ } ,
119+ encoding : 'utf-8' ,
120+ } ) ;
121+ expect ( gitInit . status ) . toBe ( 0 ) ;
122+
123+ const result = spawnSync ( 'bash' , [ fixture . scriptPath , 'local' ] , {
124+ cwd : fixture . projectRoot ,
125+ env : {
126+ ...process . env ,
127+ HOME : fixture . homeRoot ,
128+ } ,
129+ encoding : 'utf-8' ,
130+ } ) ;
131+
132+ expect ( result . status ) . toBe ( 0 ) ;
133+
134+ const excludePath = join ( fixture . projectRoot , '.git' , 'info' , 'exclude' ) ;
135+ expect ( existsSync ( excludePath ) ) . toBe ( true ) ;
136+
137+ const excludeContents = readFileSync ( excludePath , 'utf-8' ) ;
138+ expect ( excludeContents ) . toContain ( '# BEGIN OMC local artifacts' ) ;
139+ expect ( excludeContents ) . toContain ( '.omc/*' ) ;
140+ expect ( excludeContents ) . toContain ( '!.omc/skills/' ) ;
141+ expect ( excludeContents ) . toContain ( '!.omc/skills/**' ) ;
142+ expect ( excludeContents ) . toContain ( '# END OMC local artifacts' ) ;
143+ } ) ;
144+
145+ it ( 'does not duplicate the local git exclude block on repeated local setup runs' , ( ) => {
146+ const fixture = createPluginFixture ( `<!-- OMC:START -->
147+ <!-- OMC:VERSION:9.9.9 -->
148+
149+ # Canonical CLAUDE
150+ Use the real docs file.
151+ <!-- OMC:END -->
152+ ` ) ;
153+
154+ const gitInit = spawnSync ( 'git' , [ 'init' ] , {
155+ cwd : fixture . projectRoot ,
156+ env : {
157+ ...process . env ,
158+ HOME : fixture . homeRoot ,
159+ } ,
160+ encoding : 'utf-8' ,
161+ } ) ;
162+ expect ( gitInit . status ) . toBe ( 0 ) ;
163+
164+ const firstRun = spawnSync ( 'bash' , [ fixture . scriptPath , 'local' ] , {
165+ cwd : fixture . projectRoot ,
166+ env : {
167+ ...process . env ,
168+ HOME : fixture . homeRoot ,
169+ } ,
170+ encoding : 'utf-8' ,
171+ } ) ;
172+ expect ( firstRun . status ) . toBe ( 0 ) ;
173+
174+ const secondRun = spawnSync ( 'bash' , [ fixture . scriptPath , 'local' ] , {
175+ cwd : fixture . projectRoot ,
176+ env : {
177+ ...process . env ,
178+ HOME : fixture . homeRoot ,
179+ } ,
180+ encoding : 'utf-8' ,
181+ } ) ;
182+ expect ( secondRun . status ) . toBe ( 0 ) ;
183+
184+ const excludeContents = readFileSync ( join ( fixture . projectRoot , '.git' , 'info' , 'exclude' ) , 'utf-8' ) ;
185+ expect ( excludeContents . match ( / # B E G I N O M C l o c a l a r t i f a c t s / g) ) . toHaveLength ( 1 ) ;
186+ } ) ;
103187} ) ;
0 commit comments