-
Notifications
You must be signed in to change notification settings - Fork 354
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
Add a new trait to discard all tags with creation date older than the configured days #1017
base: master
Are you sure you want to change the base?
Conversation
… configured days.
@nfalco79 Added filter trait for tags similar to DiscardOldBranchTrait, but was able to use |
* Discard all tags with creation date older than the configured days. | ||
* | ||
* @author Madis Parn | ||
* @since ??? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove or write current snapshot version 936.0.0
} | ||
} | ||
|
||
public static final class ExcludeOldSCMTag extends SCMHeadPrefilter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason why SCMHeadPrefilter instead of SCMHeadFilter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, SCMHeadPrefilter is the right choice here because ExcludeOldSCMTag does not make remote requests. GitTagSCMHead.getTimestamp() simply returns the value of a field. SCMSourceRequest.isExcluded evaluates SCMHeadPrefilter before SCMHeadFilter, so if ExcludeOldSCMTag decides to exclude the tag, then no SCMHeadFilter will be evaluated and their remote requests will be avoided.
|
||
@Override | ||
public boolean isExcluded(@NonNull SCMSource source, @NonNull SCMHead head) { | ||
if (!(head instanceof BitbucketTagSCMHead tagHead)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use GitTagSCMHead instead of BitbucketTagSCMHead
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2025, CloudBees, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use you name
private final long expiryMs; | ||
|
||
public ExcludeOldSCMTag(int keepForDays) { | ||
this.expiryMs = ZonedDateTime.now().minusDays(keepForDays) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the zoned time?
} | ||
|
||
@Test | ||
void verify_that_branch_is_excluded_if_expired() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit s/branch/tag/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a natural language? what would you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this PR is about excluding tags, not branches, as currently indicated by the test method name
if (!(head instanceof BitbucketTagSCMHead tagHead)) { | ||
return false; | ||
} | ||
return tagHead.getTimestamp() < expiryMs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when tagHead.getTimestamp() is 0 do not exclude
Your checklist for this pull request