lambdacd-git icon indicating copy to clipboard operation
lambdacd-git copied to clipboard

Pass git revision as args from with-git

Open alehatsman opened this issue 7 years ago • 2 comments

Hello,

I am surprised to find that revision is not available in the next task's args after with-git. That required me to manually execute git rev-parse HEAD. In my opinion, we should get as much info as possible for the user. I mean for a developer who is going to use that lib.

How hard is it to add?

Aleh.

alehatsman avatar Apr 05 '18 13:04 alehatsman

Hi,

I feel you might be mixing up the built-in git support in LambdaCD (e.g. lambdacd.steps.git/with-git) which is deprecated with the new git support that was split out into this separate project.

In both cases, the git revision is provided by wait-for-git since this is where new, unknown revisions usually come from. Once you clone something, you need to know what you are cloning anyway.

The special case I can think of would be that you explicitly require the git-hash but are cloning from the head of a branch without specifying a specific commit. If you are using lambdacd-git, you could probably extend your clone like this:

(defn- enrich-with-cloned-revision [result cwd]
  (assoc result :cloned-revision (-> (Git/open (io/file cwd))
                                     (.getRepository)
                                     (.resolve "HEAD")
                                     (.name))))

(defn clone [args ctx]
  (-> (core/clone ctx repo-uri (:revision args) (:cwd args))
      (enrich-with-cloned-revision (:cwd args))))

If you feel this adds value as a functionality of the clone function itself, I'd be open for a PR.

flosell avatar Apr 06 '18 04:04 flosell

Hi,

Thank you for so quick reply.

Let me describe my use case. I want to pull new version or use existing. Then on build step, I need to have a revision, because I use it as docker image version. I need revision not only in case of something new in git, but also if I use a manual trigger.

I don't know, but I think that it is a good idea to provide as much information as possible out of the box. Because I know how weird build process can be and it is always better for a user to just have all properties out of the box. Maybe that is only my opinion because when I do devops I expect that from the tool.

I will try to use your snippet temporary and them will think about pr.

Thank you!

alehatsman avatar Apr 06 '18 08:04 alehatsman