-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add archived filter (JENKINS-64353) (#27)
* feat: add archived filter * Update src/main/resources/org/jenkinsci/plugin/gitea/GiteaSCMNavigator/help.html * chore: ignore files * chore: fix test * Update src/main/java/org/jenkinsci/plugin/gitea/ExcludeArchivedRepositoriesTrait.java
- Loading branch information
Showing
10 changed files
with
131 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,8 @@ work*/ | |
.project | ||
build/ | ||
|
||
# vscode | ||
bin/ | ||
/.factorypath | ||
|
||
/nb-configuration.xml |
77 changes: 77 additions & 0 deletions
77
src/main/java/org/jenkinsci/plugin/gitea/ExcludeArchivedRepositoriesTrait.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2021, CloudBees, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package org.jenkinsci.plugin.gitea; | ||
|
||
import hudson.Extension; | ||
import jenkins.scm.api.trait.SCMNavigatorContext; | ||
import jenkins.scm.api.trait.SCMNavigatorTrait; | ||
import jenkins.scm.api.trait.SCMNavigatorTraitDescriptor; | ||
import jenkins.scm.impl.trait.Selection; | ||
import org.jenkinsci.Symbol; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* A {@link Selection} trait that will restrict the discovery of repositories that have been archived. | ||
*/ | ||
public class ExcludeArchivedRepositoriesTrait extends SCMNavigatorTrait { | ||
|
||
/** | ||
* Constructor for stapler. | ||
*/ | ||
@DataBoundConstructor | ||
public ExcludeArchivedRepositoriesTrait() { | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
protected void decorateContext(SCMNavigatorContext<?, ?> context) { | ||
super.decorateContext(context); | ||
GiteaSCMNavigatorContext ctx = (GiteaSCMNavigatorContext) context; | ||
ctx.setExcludeArchivedRepositories(true); | ||
} | ||
|
||
/** | ||
* Exclude archived repositories filter | ||
*/ | ||
@Symbol("giteaExcludeArchivedRepositories") | ||
@Extension | ||
@Selection | ||
public static class DescriptorImpl extends SCMNavigatorTraitDescriptor { | ||
|
||
@Override | ||
public Class<? extends SCMNavigatorContext> getContextClass() { | ||
return GiteaSCMNavigatorContext.class; | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public String getDisplayName() { | ||
return Messages.ExcludeArchivedRepositoriesTrait_displayName(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/resources/org/jenkinsci/plugin/gitea/ExcludeArchivedTrait/config.jelly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:c="/lib/credentials" | ||
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" | ||
xmlns:f2="/org/jenkinsci/plugins/gitea/form"> | ||
</j:jelly> |
3 changes: 3 additions & 0 deletions
3
src/main/resources/org/jenkinsci/plugin/gitea/GiteaSCMNavigator/help.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div> | ||
Exclude Gitea repositories that have been archived. If set, no jobs will be created for archived repositories. | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters