CleverCloud / clever-tools

The official command line interface for Clever Cloud
https://www.clever-cloud.com/
Apache License 2.0
74 stars 46 forks source link

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

Open hsablonniere opened 6 years ago

hsablonniere commented 6 years ago

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.

billiegoose commented 6 years ago

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 commented 6 years ago

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

hsablonniere commented 6 years ago

@wmhilton No worries...