Skip to content

Commit

Permalink
TS-41699 Rework
Browse files Browse the repository at this point in the history
  • Loading branch information
DreierF committed Feb 3, 2025
1 parent 42bfbed commit 2127a10
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ private int parseInt(String key, String value) throws AgentOptionParseException
* deterministic, i.e. if you run the pattern twice and get the same set of files, the same file will be picked each
* time.
*/
public Path parsePath(String optionName, String pattern) throws AgentOptionParseException {
public static Path parsePath(FilePatternResolver filePatternResolver, String optionName, String pattern) throws AgentOptionParseException {
try {
return filePatternResolver.parsePath(optionName, pattern);
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package com.teamscale.jacoco.agent.upload.teamscale;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.jar.JarInputStream;
import java.util.jar.Manifest;

import com.teamscale.client.CommitDescriptor;
import com.teamscale.client.StringUtils;
import com.teamscale.client.TeamscaleServer;
Expand All @@ -15,6 +9,14 @@
import com.teamscale.report.util.BashFileSkippingInputStream;
import com.teamscale.report.util.ILogger;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.jar.JarInputStream;
import java.util.jar.Manifest;

import static com.teamscale.jacoco.agent.options.AgentOptionsParser.parsePath;

/** Config necessary for direct Teamscale upload. */
public class TeamscaleConfig {

Expand Down Expand Up @@ -44,7 +46,7 @@ public TeamscaleConfig(ILogger logger, FilePatternResolver filePatternResolver)
* @return true if it has successfully processed the given option.
*/
public boolean handleTeamscaleOptions(TeamscaleServer teamscaleServer,
String key, String value)
String key, String value)
throws AgentOptionParseException {
switch (key) {
case "teamscale-server-url":
Expand All @@ -66,12 +68,8 @@ public boolean handleTeamscaleOptions(TeamscaleServer teamscaleServer,
teamscaleServer.commit = parseCommit(value);
return true;
case TEAMSCALE_COMMIT_MANIFEST_JAR_OPTION:
try {
teamscaleServer.commit = getCommitFromManifest(
filePatternResolver.parsePath(key, value).toFile());
} catch (IOException e) {
throw new AgentOptionParseException(e);
}
teamscaleServer.commit = getCommitFromManifest(
parsePath(filePatternResolver, key, value).toFile());
return true;
case "teamscale-message":
teamscaleServer.setMessage(value);
Expand All @@ -83,12 +81,8 @@ public boolean handleTeamscaleOptions(TeamscaleServer teamscaleServer,
teamscaleServer.repository = value;
return true;
case TEAMSCALE_REVISION_MANIFEST_JAR_OPTION:
try {
teamscaleServer.revision = getRevisionFromManifest(
filePatternResolver.parsePath(key, value).toFile());
} catch (IOException e) {
throw new AgentOptionParseException(e);
}
teamscaleServer.revision = getRevisionFromManifest(
parsePath(filePatternResolver, key, value).toFile());
return true;
default:
return false;
Expand Down

0 comments on commit 2127a10

Please sign in to comment.