@@ -216,9 +216,16 @@ enum QueueSubcommand {
216216 /// Get the registry watcher's last seen reference
217217 GetLastSeenReference ,
218218
219- /// Set the register watcher's last seen reference
219+ /// Set the registry watcher's last seen reference
220+ #[ command( arg_required_else_help( true ) ) ]
220221 SetLastSeenReference {
221- reference : crates_index_diff:: gix:: ObjectId ,
222+ /// The reference to set to, required unless flag used
223+ #[ arg( conflicts_with( "head" ) ) ]
224+ reference : Option < crates_index_diff:: gix:: ObjectId > ,
225+
226+ /// Fetch the current HEAD of the remote index and use it
227+ #[ arg( long, conflicts_with( "reference" ) ) ]
228+ head : bool ,
222229 } ,
223230}
224231
@@ -244,8 +251,19 @@ impl QueueSubcommand {
244251 }
245252 }
246253
247- Self :: SetLastSeenReference { reference } => {
254+ Self :: SetLastSeenReference { reference, head } => {
255+ let reference = match ( reference, head) {
256+ ( Some ( reference) , false ) => reference,
257+ ( None , true ) => {
258+ println ! ( "Fetching changes to set reference to HEAD" ) ;
259+ let ( _, oid) = ctx. index ( ) ?. diff ( ) ?. peek_changes ( ) ?;
260+ oid
261+ }
262+ ( _, _) => unreachable ! ( ) ,
263+ } ;
264+
248265 ctx. build_queue ( ) ?. set_last_seen_reference ( reference) ?;
266+ println ! ( "Set last seen reference: {reference}" ) ;
249267 }
250268
251269 Self :: DefaultPriority { subcommand } => subcommand. handle_args ( ctx) ?,
0 commit comments