@@ -181,6 +181,14 @@ async function createAnnexBranch() {
181181 } )
182182}
183183
184+ /**
185+ * Generate a commit for remote.log updates if needed
186+ */
187+ async function remoteSetup ( ) {
188+ const noAnnexKeys : Record < string , string > = { }
189+ await commitAnnexBranch ( noAnnexKeys )
190+ }
191+
184192/**
185193 * Generate one commit for all pending git-annex branch changes
186194 */
@@ -225,7 +233,10 @@ async function commitAnnexBranch(annexKeys: Record<string, string>) {
225233 { encoding : "utf8" } ,
226234 )
227235 } catch ( _err ) {
228- if ( _err instanceof Error && _err . name !== "NotFound" ) {
236+ // Continue if the error is remote.log is not found, otherwise throw it here
237+ if (
238+ ! ( _err instanceof Error && "code" in _err && _err . code === "ENOENT" )
239+ ) {
229240 throw _err
230241 }
231242 } finally {
@@ -269,11 +280,23 @@ async function commitAnnexBranch(annexKeys: Record<string, string>) {
269280 await git . add ( { ...context . config ( ) , filepath : annexBranchPath } )
270281 }
271282 }
272- await git . commit ( {
273- ...context . config ( ) ,
274- message : "[OpenNeuro CLI] Added annexed objects" ,
275- author : context . author ,
276- } )
283+ // Show a better commit message for when only the remote is updated
284+ if ( Object . keys ( annexKeys ) . length === 0 ) {
285+ // Only generate a commit if needed
286+ if ( ! remoteLog . includes ( uuid ) ) {
287+ await git . commit ( {
288+ ...context . config ( ) ,
289+ message : "[OpenNeuro CLI] Configured remote" ,
290+ author : context . author ,
291+ } )
292+ }
293+ } else {
294+ await git . commit ( {
295+ ...context . config ( ) ,
296+ message : "[OpenNeuro CLI] Added annexed objects" ,
297+ author : context . author ,
298+ } )
299+ }
277300 }
278301 } finally {
279302 try {
@@ -437,6 +460,8 @@ self.onmessage = (event: GitWorkerEvent) => {
437460 workQueue . enqueue ( commit )
438461 } else if ( event . data . command === "push" ) {
439462 workQueue . enqueue ( push )
463+ } else if ( event . data . command === "remote-setup" ) {
464+ workQueue . enqueue ( remoteSetup )
440465 } else if ( event . data . command === "done" ) {
441466 workQueue . enqueue ( done )
442467 }
0 commit comments