Package jetbrains.buildServer.vcs
Class VcsUtil
- java.lang.Object
-
- jetbrains.buildServer.vcs.VcsUtil
-
public class VcsUtil extends java.lang.Object
Various utility methods for VcsRoot- Since:
- 8.0
- Author:
- kir
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
BRANCH_SPEC_PROP
static java.lang.String
CHECKOUT_ROOT
static java.lang.String
VCS_NAME_PROP
static java.lang.String
VCS_ROOT_NAME_PROP
-
Constructor Summary
Constructors Constructor Description VcsUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
areEquivalentRoots(VcsRoot root1, VcsRoot root2)
Checks whether the specified VCS roots are equivalent.static VcsRoot
convertStringToVcsRoot(long id, java.lang.String serialized)
Deserialized VCS root from Stringstatic VcsRoot
convertStringToVcsRoot(long id, java.lang.String serialized, Function<java.lang.String,java.lang.String> decode)
Deserialized VCS root from Stringstatic java.lang.String
convertVcsRootToString(VcsRoot root)
Serializes VCS root contents without id to string.static java.lang.String
convertVcsRootToString(VcsRoot root, Function<java.lang.String,java.lang.String> encode)
Serializes VCS root contents without id to stringstatic java.lang.String
getSimplifiedName(VcsRoot vcsRoot)
static java.lang.String
getVcsRootPropertiesAsPresentableString(VcsRoot root)
static long
getVcsRootPropertiesHash(VcsRoot root)
static java.util.Map<java.lang.String,java.lang.String>
getVcsRootPublicProperties(VcsRoot root)
static boolean
isSecureProperty(java.lang.String propertyName)
Returns true if the property is secure, i.e.static boolean
isSet(VcsRoot root, java.lang.String propertyName)
static java.lang.String
propertiesToString(java.util.Map<java.lang.String,java.lang.String> properties)
Converts properties set to string, without any transformation of the secured propertiesstatic java.lang.String
propertiesToString(java.util.Map<java.lang.String,java.lang.String> properties, boolean scrambleSecureProps)
Converts properties set to string, with optional scrambling of the secured propertiesstatic java.lang.String
propertiesToStringSecure(java.util.Map<java.lang.String,java.lang.String> properties)
Converts properties set to string, with scrambling of the secure propertiesstatic java.util.Map<java.lang.String,java.lang.String>
stringToProperties(java.lang.String string)
Converts string to map of properties.static java.util.Map<java.lang.String,java.lang.String>
stringToProperties(java.lang.String string, boolean unscrambleSecureProps)
Converts string to map of properties.static java.util.Map<java.lang.String,java.lang.String>
stringToPropertiesAsIs(java.lang.String string)
Converts string to map of properties.static java.util.Map<java.lang.String,java.lang.String>
stringToPropertiesSecure(java.lang.String string, Function<java.lang.String,java.lang.String> decript)
Converts string to map of properties.
-
-
-
Field Detail
-
VCS_NAME_PROP
@NonNls public static final java.lang.String VCS_NAME_PROP
- See Also:
- Constant Field Values
-
VCS_ROOT_NAME_PROP
@NonNls public static final java.lang.String VCS_ROOT_NAME_PROP
- See Also:
- Constant Field Values
-
BRANCH_SPEC_PROP
@NonNls public static final java.lang.String BRANCH_SPEC_PROP
- See Also:
- Constant Field Values
-
CHECKOUT_ROOT
@NonNls public static final java.lang.String CHECKOUT_ROOT
- See Also:
- Constant Field Values
-
-
Method Detail
-
areEquivalentRoots
public static boolean areEquivalentRoots(@Nullable VcsRoot root1, @Nullable VcsRoot root2)
Checks whether the specified VCS roots are equivalent. VCS roots are considered equivalent if they both represent same VcsSupport and contain same properties.- Parameters:
root1
- VCS rootroot2
- VCS root- Returns:
- true if roots are equivalent
-
getVcsRootPublicProperties
@NotNull public static java.util.Map<java.lang.String,java.lang.String> getVcsRootPublicProperties(@NotNull VcsRoot root)
- Returns:
- return VcsRoot properties filtering secured once
- Since:
- 8.1
-
getVcsRootPropertiesHash
public static long getVcsRootPropertiesHash(@NotNull VcsRoot root)
- Returns:
- hash of properties of given VcsRoot
- Since:
- 8.1
-
getVcsRootPropertiesAsPresentableString
@NotNull public static java.lang.String getVcsRootPropertiesAsPresentableString(@NotNull VcsRoot root)
- Returns:
- string presentation for given VCS root
- Since:
- 8.2
-
convertVcsRootToString
@NotNull public static java.lang.String convertVcsRootToString(@NotNull VcsRoot root)
Serializes VCS root contents without id to string. Secured values are scrambled during conversion. If you need to use encryption please @see #convertVcsRootToString(VcsRoot, Function)- Parameters:
root
- root to serialize- Returns:
- string representation
- See Also:
convertStringToVcsRoot(long, String)
-
convertVcsRootToString
@NotNull public static java.lang.String convertVcsRootToString(@NotNull VcsRoot root, Function<java.lang.String,java.lang.String> encode)
Serializes VCS root contents without id to string- Parameters:
root
- root to serializeencode
- function to transform secured values- Returns:
- string representation
- Since:
- 2020.1
- See Also:
convertStringToVcsRoot(long, String)
-
convertStringToVcsRoot
@NotNull public static VcsRoot convertStringToVcsRoot(long id, @NotNull java.lang.String serialized)
Deserialized VCS root from String- Parameters:
id
- root idserialized
- serialized root string fromconvertVcsRootToString(VcsRoot)
- Returns:
- deserialized VCS root
- Since:
- 8.1
- See Also:
convertVcsRootToString(VcsRoot)
-
convertStringToVcsRoot
@NotNull public static VcsRoot convertStringToVcsRoot(long id, @NotNull java.lang.String serialized, Function<java.lang.String,java.lang.String> decode)
Deserialized VCS root from String- Parameters:
id
- root idserialized
- serialized root string fromconvertVcsRootToString(VcsRoot, Function)
decode
- function to transform secured values back- Returns:
- deserialized VCS root
- Since:
- 2020.1
- See Also:
convertVcsRootToString(VcsRoot, Function)
-
getSimplifiedName
@NotNull public static java.lang.String getSimplifiedName(@NotNull VcsRoot vcsRoot)
- Parameters:
vcsRoot
- VcsRoot for which we need normalized name- Returns:
- symbolic normalized name of the VcsRoot
-
isSecureProperty
public static boolean isSecureProperty(@NotNull java.lang.String propertyName)
Returns true if the property is secure, i.e. its value should be scrambled when property persisted.- Parameters:
propertyName
- property name.- Returns:
true
if property value should be scrambled.
-
propertiesToStringSecure
@NotNull public static java.lang.String propertiesToStringSecure(@NotNull java.util.Map<java.lang.String,java.lang.String> properties)
Converts properties set to string, with scrambling of the secure properties- Parameters:
properties
- map of properties values.- Returns:
- string properties presentation.
- See Also:
stringToProperties(String)
,VcsRoot.SECURE_PROPERTY_PREFIX
-
propertiesToString
@NotNull public static java.lang.String propertiesToString(@NotNull java.util.Map<java.lang.String,java.lang.String> properties, boolean scrambleSecureProps)
Converts properties set to string, with optional scrambling of the secured properties- Parameters:
properties
- map of properties values.scrambleSecureProps
- if true, secure properties will be scrambled to avoid their reading in plain text- Returns:
- string properties presentation.
- See Also:
stringToProperties(String)
,VcsRoot.SECURE_PROPERTY_PREFIX
-
propertiesToString
@NotNull public static java.lang.String propertiesToString(@NotNull java.util.Map<java.lang.String,java.lang.String> properties)
Converts properties set to string, without any transformation of the secured properties- Parameters:
properties
- map of properties values.- Returns:
- string properties presentation.
- See Also:
stringToProperties(String)
-
stringToProperties
@NotNull public static java.util.Map<java.lang.String,java.lang.String> stringToProperties(java.lang.String string)
Converts string to map of properties.- Parameters:
string
- original string.- Returns:
- map of properties.
- See Also:
VcsUtil#propertiesToStringSecure(java.util.Map, boolean)
-
stringToProperties
@NotNull public static java.util.Map<java.lang.String,java.lang.String> stringToProperties(java.lang.String string, boolean unscrambleSecureProps)
Converts string to map of properties.- Parameters:
string
- original string.unscrambleSecureProps
- if true, will try to unscramble secure properties- Returns:
- map of properties.
- Since:
- 2018.2
- See Also:
propertiesToString(java.util.Map, boolean)
-
stringToPropertiesAsIs
@NotNull public static java.util.Map<java.lang.String,java.lang.String> stringToPropertiesAsIs(java.lang.String string)
Converts string to map of properties.- Parameters:
string
- original string.- Returns:
- map of properties.
- Since:
- 2020.1
- See Also:
VcsUtil#propertiesToStringSecure(java.util.Map, boolean)
-
stringToPropertiesSecure
@NotNull public static java.util.Map<java.lang.String,java.lang.String> stringToPropertiesSecure(java.lang.String string, Function<java.lang.String,java.lang.String> decript)
Converts string to map of properties.- Parameters:
string
- original string.decript
- method will try to transform secure properties by using this function- Returns:
- map of properties.
- Since:
- 2020.1
- See Also:
propertiesToString(java.util.Map, boolean)
-
isSet
public static boolean isSet(@NotNull VcsRoot root, java.lang.String propertyName)
- Returns:
- true if property option is set in the VcsRoot
- Since:
- 10.0
-
-