Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.

Pass git revision as args from with-git #30

Open
alehatsman opened this issue Apr 5, 2018 · 2 comments
Open

Pass git revision as args from with-git #30

alehatsman opened this issue Apr 5, 2018 · 2 comments

Comments

@alehatsman
Copy link

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.

@flosell
Copy link
Owner

flosell commented Apr 6, 2018

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.

@alehatsman
Copy link
Author

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!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants