Skip to content

Commit

Permalink
Merge pull request #2378 from SiemensEnergy/fix/sourceCodeUploadForRe…
Browse files Browse the repository at this point in the history
…lease

fix(SRCUploadService): Source upload should work for release versions having alphanumeric characters

Reviewed by: afsah.syeda@siemens-healthineers.com
Tested by: sameed.ahmad@siemens-healthineers.com
  • Loading branch information
ag4ums committed Apr 17, 2024
2 parents aa57ca5 + e5ac927 commit 6d12f46
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3070,7 +3070,8 @@ public RequestStatus uploadSourceCodeAttachmentToReleases() {
components.forEach(c -> {
String VCS = c.getVcs();
log.info(String.format("SRC Upload: %s %s", c.getId(), VCS));
if (isValidURL(VCS)) {
// Add more domains in the future and include the download logic accordingly
if (VCS.toLowerCase().contains("github.com")) {
for (String r_id : c.getReleaseIds()) {
boolean isUploaded = false;
Release r = getRelease(r_id);
Expand Down Expand Up @@ -3150,10 +3151,9 @@ private boolean isValidURL(String url) {

public File downloadFile(String url, String destinationDirectory) throws IOException {
URL fileUrl = new URL(url);
String regex = ".*/([^/]+)/archive/refs/tags/(?:v)?([\\d.]+)\\.zip$";
String regex = ".*/([^/]+)/archive/refs/tags/(?:v)?(.*).zip$";
String fileName = url.replaceAll(regex, "$1-$2.zip");
Path destinationPath = Paths.get(destinationDirectory, fileName);

Path destinationPath = Paths.get(destinationDirectory, fileName.replace("/","-"));
try (InputStream in = fileUrl.openStream()) {
Files.copy(in, destinationPath, StandardCopyOption.REPLACE_EXISTING);
}
Expand Down

0 comments on commit 6d12f46

Please sign in to comment.