clever-tools icon indicating copy to clipboard operation
clever-tools copied to clipboard

Add `--tag` option to `clever restart`

Open hsablonniere opened this issue 6 years ago • 3 comments

Right now, with the new isomorphic-git based clever-tools, we cannot resolve the commit id of a tag. This is mandatory for us to call the API with the right commit id to restart.

We filed an issue and proposed a solution.

When this is available, we'll be able to add an option to clever restart called --tag to call the API with the right SHA1 to restart.

hsablonniere avatar Oct 12 '18 15:10 hsablonniere

I'll probably get a convenience function that makes this easy later tonight or tomorrow, but if I don't it's relatively easy to work around:

import { readObject, resolveRef } from 'isomorphic-git'

function resolveCommit (oid) {
  let { type, object } = await readObject({ gitdir, oid })
  if (type === 'commit') return oid
  // Recursively resolve annotated tags
  if (type === 'tag') return resolveCommit(object.object)
  // else
  throw Error(`wow, seriously did not expect a ${type}` here)
}

let oid = resolveRef({ gitdir, ref })
oid = resolveCommit(oid)

^ completely untested. Because if I tested it then I'd probably have published it already.

billiegoose avatar Oct 13 '18 23:10 billiegoose

FYI, I haven't gotten around to it. Been stuck on a stupid bug fighting with my CI system.

billiegoose avatar Oct 16 '18 05:10 billiegoose

@wmhilton No worries...

hsablonniere avatar Oct 17 '18 08:10 hsablonniere