Skip to content

Commit

Permalink
TS-38561 Resolve first set of Teamscale findings
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonymFx committed May 22, 2024
1 parent 2001810 commit c8f3507
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public class CommitInfo {
/** The commit descriptor. */
public CommitDescriptor commit;

/**
* If the commit property is set via the <code>teamscale.timestamp</code> property in a git.properties file, this
* should be preferred to the revision. For details see <a
* href="https://cqse.atlassian.net/browse/TS-38561">TS-38561</a>.
*/
public boolean preferCommitDescriptorOverRevision = false;

/** Constructor. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class GitPropertiesLocatorUtils {

/**
* You can provide a teamscale timestamp in git.properties files to overwrite the revision. See <a
* href="https://cqse.atlassian.net/browse/TS-38561">...</a>.
* href="https://cqse.atlassian.net/browse/TS-38561">TS-38561</a>.
*/
static final String GIT_PROPERTIES_TEAMSCALE_TIMESTAMP = "teamscale.timestamp";

Expand All @@ -65,7 +65,16 @@ public class GitPropertiesLocatorUtils {
private static final Pattern NESTED_JAR_REGEX = Pattern.compile("[jwea]ar:file:(.*?)\\*(.*)",
Pattern.CASE_INSENSITIVE);

/**
* Defined in <a
* href="https://github.com/git-commit-id/git-commit-id-maven-plugin/blob/ac05b16dfdcc2aebfa45ad3af4acf1254accffa3/src/main/java/pl/project13/maven/git/GitCommitIdMojo.java#L522">GitCommitIdMojo</a>
*/
private static final String GIT_PROPERTIES_DEFAULT_MAVEN_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ssXXX";

/**
* Defined in <a
* href="https://github.com/n0mer/gradle-git-properties/blob/bb1c3353bb570495644b6c6c75e211296a8354fc/src/main/groovy/com/gorylenko/GitPropertiesPlugin.groovy#L68">GitPropertiesPlugin</a>
*/
private static final String GIT_PROPERTIES_DEFAULT_GRADLE_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ";

/** File ending of Java archive packages */
Expand Down Expand Up @@ -355,7 +364,7 @@ public static CommitInfo getCommitInfoFromGitProperties(
long gitTimestamp = 0;
try {
gitTimestamp = ZonedDateTime.parse(gitTime, dateTimeFormatter).toInstant().toEpochMilli();
} catch (Exception e) {
} catch (DateTimeParseException e) {
throw new InvalidGitPropertiesException(
"Could not parse the timestamp in property '" + GIT_PROPERTIES_GIT_COMMIT_TIME + "'." +
"\nIn " + entryName + " in " + jarFile + "." +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,20 +223,4 @@ public static List<CommitInfo> parseGitProperties(File file, boolean isJarFile,

return result;
}

/**
* Returns a value from a git properties file.
*/
private static String getGitPropertiesValue(Properties gitProperties, String key, String entryName, File jarFile)
throws InvalidGitPropertiesException {
String value = gitProperties.getProperty(key);
if (StringUtils.isEmpty(value)) {
throw new InvalidGitPropertiesException("No entry or empty value for '" + key + "' in " + entryName + " in "
+ jarFile + "." + "\nContents of " + GitPropertiesLocatorUtils.GIT_PROPERTIES_FILE_NAME + ":\n"
+ gitProperties);
}

return value;
}

}

0 comments on commit c8f3507

Please sign in to comment.