Package jetbrains.buildServer.vcs
Class VcsUtil
- java.lang.Object
-
- jetbrains.buildServer.vcs.VcsUtil
-
public class VcsUtil extends Object
Various utility methods for VcsRoot- Since:
- 8.0
- Author:
- kir
-
-
Field Summary
Fields Modifier and Type Field Description static String
BRANCH_SPEC_PROP
static String
CHECKOUT_ROOT
static String
VCS_NAME_PROP
static 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, String serialized)
Deserialized VCS root from Stringstatic VcsRoot
convertStringToVcsRoot(long id, String serialized, Function<String,String> decode)
Deserialized VCS root from Stringstatic String
convertVcsRootToString(VcsRoot root)
Serializes VCS root contents without id to string.static String
convertVcsRootToString(VcsRoot root, Function<String,String> encode)
Serializes VCS root contents without id to stringstatic String
getSimplifiedName(VcsRoot vcsRoot)
static String
getVcsRootPropertiesAsPresentableString(VcsRoot root)
static long
getVcsRootPropertiesHash(VcsRoot root)
static Map<String,String>
getVcsRootPublicProperties(VcsRoot root)
static boolean
isSecureProperty(String propertyName)
Returns true if the property is secure, i.e.static boolean
isSet(VcsRoot root, String propertyName)
static String
propertiesToString(Map<String,String> properties)
Converts properties set to string, without any transformation of the secured propertiesstatic String
propertiesToString(Map<String,String> properties, boolean scrambleSecureProps)
Converts properties set to string, with optional scrambling of the secured propertiesstatic String
propertiesToStringSecure(Map<String,String> properties)
Converts properties set to string, with scrambling of the secure propertiesstatic Map<String,String>
stringToProperties(String string)
Converts string to map of properties.static Map<String,String>
stringToProperties(String string, boolean unscrambleSecureProps)
Converts string to map of properties.static Map<String,String>
stringToPropertiesAsIs(String string)
Converts string to map of properties.static Map<String,String>
stringToPropertiesSecure(String string, Function<String,String> decript)
Converts string to map of properties.
-
-
-
Field Detail
-
VCS_NAME_PROP
@NonNls public static final String VCS_NAME_PROP
- See Also:
- Constant Field Values
-
VCS_ROOT_NAME_PROP
@NonNls public static final String VCS_ROOT_NAME_PROP
- See Also:
- Constant Field Values
-
BRANCH_SPEC_PROP
@NonNls public static final String BRANCH_SPEC_PROP
- See Also:
- Constant Field Values
-
CHECKOUT_ROOT
@NonNls public static final 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 Map<String,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 String getVcsRootPropertiesAsPresentableString(@NotNull VcsRoot root)
- Returns:
- string presentation for given VCS root
- Since:
- 8.2
-
convertVcsRootToString
@NotNull public static 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 String convertVcsRootToString(@NotNull VcsRoot root, Function<String,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 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 String serialized, Function<String,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 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 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 String propertiesToStringSecure(@NotNull Map<String,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 String propertiesToString(@NotNull Map<String,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 String propertiesToString(@NotNull Map<String,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 Map<String,String> stringToProperties(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 Map<String,String> stringToProperties(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 Map<String,String> stringToPropertiesAsIs(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 Map<String,String> stringToPropertiesSecure(String string, Function<String,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)
-
-