Package jetbrains.buildServer.vcs
Class CheckoutRules
- java.lang.Object
-
- jetbrains.buildServer.vcs.FileRuleSet<IncludeRule,FileRule>
-
- jetbrains.buildServer.vcs.CheckoutRules
-
- All Implemented Interfaces:
Loggable
public class CheckoutRules extends FileRuleSet<IncludeRule,FileRule>
Contains a number of rules how to layout project sources on agent side.
-
-
Field Summary
Fields Modifier and Type Field Description static CheckoutRules
DEFAULT
static String
INCLUDE_SEP
-
Fields inherited from class jetbrains.buildServer.vcs.FileRuleSet
EXCLUDE_PREFIX, IGNORE_CASE_MARK, INCLUDE_PREFIX
-
-
Constructor Summary
Constructors Constructor Description CheckoutRules(String body)
Creates new checkout rules instance on string rules presentation.CheckoutRules(List<String> lines)
Creates new checkout rules instance on a list of string rules.CheckoutRules(List<IncludeRule> includeRules, List<FileRule> excludeRules)
Creates rules object on include and exclude rules lists.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsWildcards()
Checks if some rule from the set contains wildcards.static CheckoutRules
createCommonRule(List<CheckoutRules> ruleses)
Creates 'union' ruleprotected FileRule
createNewExcludeRule(String line)
protected FileRule
createNewExcludeRule(FileRule rule)
protected IncludeRule
createNewIncludeRule(String rule)
protected IncludeRule
createNewIncludeRule(IncludeRule includeRule)
CheckoutRules
createNewRulesForPrefix(String prefixPath)
Creates new checkout rule set with prefix appended to every rule right part.static CheckoutRules
createOn(String ruleStr)
Creates new rule set on the specified rules string presentation.protected void
doPostInitProcess(List<IncludeRule> includeRules, List<FileRule> excludeRules)
String
getAsString()
List<IncludeRule>
getRootIncludeRules()
Returns include rules sorted by from part.boolean
includesAny(Collection<String> paths)
Returns true if these checkout rules include at least one of the specified paths.static boolean
isCorrect(String line)
Returns true if line represents syntactically correct include or exclude rule.boolean
isIncludeAll()
String
map(String path)
Maps vcs relative file path to path described by checkout rules.Collection<String>
map(Collection<String> paths)
Maps a collection of vcs relative file path to path described by checkout rules, non-matched paths from the collection is skippedprotected void
postProcessCreatedRules(List<IncludeRule> includeRules, List<FileRule> excludeRules)
boolean
shouldInclude(String path)
boolean
shouldInclude(String path, Map<String,String> props)
protected boolean
shouldInclude(String path, Filter<FileRule> includeExcludeRulesFilter)
boolean
shouldInclude(String path, IncludeRule rule)
String
toString()
-
Methods inherited from class jetbrains.buildServer.vcs.FileRuleSet
convertToLines, createPropertiesFilter, describe, equals, findMostSpecific, getBody, getExcludeRules, getExcludeRules, getIncludeRuleFor, getIncludeRuleMerged, getIncludeRules, getIncludeRules, hashCode, isEmpty, isIgnoreCase, isSubDir, isUnder, preparePath, setIgnoreCase, shouldInclude, sortByFrom
-
-
-
-
Field Detail
-
DEFAULT
public static final CheckoutRules DEFAULT
-
INCLUDE_SEP
public static final String INCLUDE_SEP
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CheckoutRules
public CheckoutRules(@NotNull List<String> lines)
Creates new checkout rules instance on a list of string rules.- Parameters:
lines
- list of string rules, lines should not contain newline characters
-
CheckoutRules
public CheckoutRules(@NotNull String body)
Creates new checkout rules instance on string rules presentation.- Parameters:
body
- string rule presentation.
-
CheckoutRules
public CheckoutRules(@NotNull List<IncludeRule> includeRules, @NotNull List<FileRule> excludeRules)
Creates rules object on include and exclude rules lists.- Parameters:
includeRules
- include rules list.excludeRules
- exclude rules list.
-
-
Method Detail
-
map
@NotNull public Collection<String> map(@NotNull Collection<String> paths)
Maps a collection of vcs relative file path to path described by checkout rules, non-matched paths from the collection is skipped- Parameters:
paths
- to map- Returns:
- collection of paths which were successfully matched
- Since:
- 10.0
- See Also:
map(String)
-
map
@Nullable public String map(String path)
Maps vcs relative file path to path described by checkout rules.- Parameters:
path
- to map- Returns:
- mapped path or null if path should be skipped.
-
isIncludeAll
public boolean isIncludeAll()
- Returns:
- true if the current checkout rules include all paths (even though some of the paths are remapped)
-
includesAny
public boolean includesAny(@NotNull Collection<String> paths)
Returns true if these checkout rules include at least one of the specified paths.- Parameters:
paths
- paths to check- Returns:
- see above
- Since:
- 2020.1.2
-
shouldInclude
public boolean shouldInclude(String path)
- Overrides:
shouldInclude
in classFileRuleSet<IncludeRule,FileRule>
-
shouldInclude
public boolean shouldInclude(String path, Map<String,String> props)
- Overrides:
shouldInclude
in classFileRuleSet<IncludeRule,FileRule>
-
shouldInclude
protected boolean shouldInclude(String path, @NotNull Filter<FileRule> includeExcludeRulesFilter)
- Overrides:
shouldInclude
in classFileRuleSet<IncludeRule,FileRule>
-
shouldInclude
public boolean shouldInclude(String path, @NotNull IncludeRule rule)
- Overrides:
shouldInclude
in classFileRuleSet<IncludeRule,FileRule>
-
createCommonRule
@NotNull public static CheckoutRules createCommonRule(@NotNull List<CheckoutRules> ruleses)
Creates 'union' rule- Parameters:
ruleses
- given rule set.- Returns:
- union rule.
-
getAsString
@NotNull public String getAsString()
- Returns:
- checkout rule set string presentation.
-
isCorrect
public static boolean isCorrect(@NotNull String line)
Returns true if line represents syntactically correct include or exclude rule. Note that empty line is considered correct.- Parameters:
line
- include or exclude rule- Returns:
- true if line is correct
-
getRootIncludeRules
public List<IncludeRule> getRootIncludeRules()
Returns include rules sorted by from part. Some include rules may be omitted if they are completely included by other rules.- Returns:
- all include rules.
-
createNewRulesForPrefix
@NotNull public CheckoutRules createNewRulesForPrefix(@NotNull String prefixPath)
Creates new checkout rule set with prefix appended to every rule right part.- Parameters:
prefixPath
- specified prefix.- Returns:
- new rule set.
-
postProcessCreatedRules
protected void postProcessCreatedRules(List<IncludeRule> includeRules, List<FileRule> excludeRules)
- Overrides:
postProcessCreatedRules
in classFileRuleSet<IncludeRule,FileRule>
-
doPostInitProcess
protected void doPostInitProcess(@NotNull List<IncludeRule> includeRules, @NotNull List<FileRule> excludeRules)
- Specified by:
doPostInitProcess
in classFileRuleSet<IncludeRule,FileRule>
-
createNewIncludeRule
protected IncludeRule createNewIncludeRule(String rule)
- Specified by:
createNewIncludeRule
in classFileRuleSet<IncludeRule,FileRule>
-
createNewExcludeRule
protected FileRule createNewExcludeRule(String line)
- Specified by:
createNewExcludeRule
in classFileRuleSet<IncludeRule,FileRule>
-
createNewIncludeRule
protected IncludeRule createNewIncludeRule(IncludeRule includeRule)
- Specified by:
createNewIncludeRule
in classFileRuleSet<IncludeRule,FileRule>
-
createNewExcludeRule
protected FileRule createNewExcludeRule(FileRule rule)
- Specified by:
createNewExcludeRule
in classFileRuleSet<IncludeRule,FileRule>
-
createOn
public static CheckoutRules createOn(String ruleStr)
Creates new rule set on the specified rules string presentation.- Parameters:
ruleStr
- specified rule set string presentation.- Returns:
- new rule set object.
-
containsWildcards
public boolean containsWildcards()
Checks if some rule from the set contains wildcards.- Returns:
true
if some rule from the set contains wildcard,false
otherwise.
-
-