Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[check] Allow triggering with tag updates #223

Merged
merged 6 commits into from
Dec 11, 2018
Merged

[check] Allow triggering with tag updates #223

merged 6 commits into from
Dec 11, 2018

Conversation

talset
Copy link
Contributor

@talset talset commented Oct 26, 2018

From a customer usecase, they use git tag like the docker way by updating static tag on new release:

git tag can be updating by changing the commit associeted

git tag DEV
git push origin DEV

# make changes
git commit

git tag DEV --force
git push origin DEV --force

Current git resource is only watch tags name but not tags update. So pipelines aren't triggered when the tag is updated and if the tag if from a different branch from the specified (or master) the resource fail with error: pathspec 'DEV' did not match any file(s) known to git.
To solve it I suggest to not use only ref but ref and commit when tag_filter is used.

This commit allow to store the tag name and commit id associeted to the tag as "version" of the resource. With thos way we are able to re-trigger the pipeline when a the tags is updated.

Here is an example or resource output with tag_filters:

  [
    {
      "ref": "2.0-staging",
      "commit": "73128e2cf79e5547c1ef292bc34de3b84f590b8d"
    },
    {
      "ref": "3.0-staging",
      "commit": "51af5f19c36833064c6d51d88af7495c8dcfa512"
    }
  ]

resource versions can be enabled or disabled as well

tmp zflxpjcth5_screenshot

Let me know if something need to be changed

@vito
Copy link
Member

vito commented Nov 19, 2018

This seems to overlap with #225 which was submitted later but seems a bit more thorough. Do you mind if we just focus our efforts on that PR?

Thanks for submitting though!

@vito vito added the blocked label Nov 19, 2018
@talset
Copy link
Contributor Author

talset commented Nov 19, 2018

@vito thx for your answer. Well as you want, we can fix the --tags part on #225 (I going to comment few question/changes) and them "rebase" this PR regarding "Adding commit id with ref in order to be able to override tag

@talset
Copy link
Contributor Author

talset commented Nov 20, 2018

@vito

This seems to overlap with #225 which was submitted later but seems a bit more thorough. Do you mind if we just focus our efforts on that PR?

After verification it would have been easier to continue on this one. The only 2 things missing are the unit test and the line git with sed. But it's your call ;)

My suggestion have been added on #225

@vito
Copy link
Member

vito commented Dec 3, 2018

@talset Thanks for your help on the other PR! Now that I look at it these two have different end goals so that would explain the difference in testing. Didn't mean to imply theirs was particularly better or anything. 🙂 But at least we can get the other one in first to reduce merge conflicts.

$tag_filter is a variable not a directory. The check should be -n not
-d.
Current git resource is only watch tags name but not tags update. So
pipelines aren't triggered when the tag is updated and the resource

with `error: pathspec 'DEV' did not match any file(s) known to git.`
To solve it I suggest to not use only ref but ref and commit when
tag_filter is used.
This commit allow to store the tag name and commit id associeted to

tag as "version" of the resource. With thos way we are able to
re-trigger the pipeline when a the tags is updated.
Add --force option on git tag in order to be able to update existing
tag.
It help to test the filter_tags code by validating a changes on the
tag commit.
When no branch are specified it clone master. We dont need to get all
branches, so we can use --single-branch as previously even if no branch
are specified.
--list is only required once
@talset
Copy link
Contributor Author

talset commented Dec 4, 2018

Thanks @vito, I rebased my commit and keep the only missing part to add commit and ref when we are using tags.

Let me know if something need to be changed.

@@ -34,7 +34,7 @@ configure_git_global "${git_config_payload}"
destination=$TMPDIR/git-resource-repo-cache

tagflag=""
if [ -d $tag_filter ]; then

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

vito added a commit that referenced this pull request Dec 4, 2018
@prein
Copy link

prein commented Dec 11, 2018

I need this improvement for my workflow too. My understanding is that the change introduced with #225 is sufficient but it still make sense to wait for this one for additional functionality (commit and ref). Correct? Is there anything stopping you from merging this?

Copy link
Member

@vito vito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prein Just a vacation. 🙂 Back now and I can get back to reviewing.

@talset Thanks for your patience! Just a couple changes requested.

assets/check Outdated
get_commit(){
for TAG in $*; do
COMMIT=$(git rev-list -n 1 $TAG)
echo "{ \"ref\": \"$TAG\", \"commit\": \"$COMMIT\" }"

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Suggested by vito: use jq just in case someone has funny tag names.
Use lowercase variables
tagflag="--tags"
fi

git clone $depthflag $uri $branchflag $destination $tagflag
git clone --single-branch $depthflag $uri $branchflag $destination $tagflag

This comment was marked as spam.

Copy link
Member

@vito vito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks!

@vito vito added enhancement and removed blocked labels Dec 11, 2018
@vito vito merged commit 885d86e into concourse:master Dec 11, 2018
@michaelklishin
Copy link

Any chance for a new release that would include this?

@talset
Copy link
Contributor Author

talset commented Dec 21, 2018

@michaelklishin

Any chance for a new release that would include this?

I don't know when it will be realesed on the official docker hub but If you need it temporarly you can use mine cycloid/concourse-git-resource:latest

@vito
Copy link
Member

vito commented Dec 22, 2018

@michaelklishin @talset Just published 1.1, sorry for the delay! It's available on Docker Hub as concourse/git-resource:1.1 (and latest/1/1.1.0).

@lancempoe
Copy link

lancempoe commented Apr 12, 2019

Will this fix the original problem, #74, that any behavior having to do with tags (tag_filter) ignore branches completely?

@talset
Copy link
Contributor Author

talset commented Apr 12, 2019

This PR fix only the ability to replace an existing tag but the previous PR with

if [ -n "$tag_filter" ]; then
  tagflag="--tags"
fi

do the job of ignore branches for tag_filter

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

Successfully merging this pull request may close these issues.

6 participants