@@ -216,9 +216,16 @@ enum QueueSubcommand {
216
216
/// Get the registry watcher's last seen reference
217
217
GetLastSeenReference ,
218
218
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 ) ) ]
220
221
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 ,
222
229
} ,
223
230
}
224
231
@@ -244,8 +251,19 @@ impl QueueSubcommand {
244
251
}
245
252
}
246
253
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
+
248
265
ctx. build_queue ( ) ?. set_last_seen_reference ( reference) ?;
266
+ println ! ( "Set last seen reference: {reference}" ) ;
249
267
}
250
268
251
269
Self :: DefaultPriority { subcommand } => subcommand. handle_args ( ctx) ?,
0 commit comments