omni icon indicating copy to clipboard operation
omni copied to clipboard

`time`: add command to restore to an older global state

Open xaf opened this issue 1 year ago • 0 comments

Depends on https://github.com/XaF/omni/issues/749

We can call global state the state at a given time of the work directories in the omni path and of the environment of those work directories.

We should provide as part of omni a time machine approach:

  • provide a date and time, and we restore omni's global state at that time (git checkout of the commit in the repository at that time + restoration of the environment the repository was using at that time)
  • potential ability to select what to restore ? (specific repositories ? only environment and not git checkout ? etc.)
  • "navigate" through time to see all the changes to the global state

This could be exposed as:

  • omni time
  • omni config time
  • omni config timetravel
  • omni config timemachine

With for tentative subcommands, e.g.:

omni time travel [options] <timestamp>
  # travels to a specific point in time 
  # timestamp could be absolute, relative or maybe even git format like HEAD~3 for "3 states before current"
  --repos <repo1,repo2>     Only restore specified repositories
  --env-only                Only restore environment state, skip git checkout
  --code-only               Only restore repository state, skip environment
  --dry-run                 Show what would be restored without making changes

(note: https://github.com/conradludgate/interim could be used to parse the timestamp)

omni time explore [options]
  # Sees the log of what is being saved in time
  --repos <repo1,repo2>     Filter by repositories
  --env-only                Show only environment changes
  --code-only               Show only repository changes
  --from <timestamp>        Start date
  --to <timestamp>          End date
omni time return
  # Restores everything to latest state

And with configuration options:

time:
  retention: <duration, default 30 days>  # specify how long to keep states for after they stop being used

xaf avatar Nov 03 '24 04:11 xaf