Skip to content

Commit

Permalink
If not define owner then ignore pr
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhoan-axonivy committed Dec 26, 2024
1 parent e9e5e74 commit a2f436c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected byte[] loadReferenceFileContent(String repoURL) throws IOException {
return String.format(CODE_OWNER_FORMAT, codeOwner.owner).getBytes();
}
}
return new byte[0];
return null;
}

private List<CodeOwner> getAllCodeOwners() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ private GHContent getFileContent(String path, GHRepository repo) {
}

private boolean hasSimilarContent(GHContent existingFile) throws IOException {
Reader targetContent = new CharSequenceReader(new String(loadReferenceFileContent(existingFile.getGitUrl())));
var fileContent = loadReferenceFileContent(existingFile.getGitUrl());
if (fileContent == null) {
return true;
}
Reader targetContent = new CharSequenceReader(new String(fileContent));
Reader actualContent;
try (var inputStream = existingFile.read()) {
actualContent = new CharSequenceReader(new String(inputStream.readAllBytes()));
Expand All @@ -106,13 +110,17 @@ private void handleMissingFile(GHRepository repo) throws IOException {
}

private void addMissingFile(GHRepository repo) throws IOException {
var fileContent = loadReferenceFileContent(repo.getUrl().toString());
if (fileContent == null) {
return;
}
var defaultBranch = repo.getBranch(repo.getDefaultBranch());
String refURL = createBranchIfMissing(repo, BRANCH_PREFIX + reference.meta().branchName(), defaultBranch.getSHA1());
try {
repo.createContent()
.branch(refURL)
.path(reference.meta().filePath())
.content(loadReferenceFileContent(repo.getUrl().toString()))
.content(fileContent)
.message(reference.meta().commitMessage())
.commit();
} catch (GHFileNotFoundException notFoundException) {
Expand Down Expand Up @@ -181,6 +189,10 @@ private void handleOtherContent(GHRepository repo) throws IOException {
}

private void updateFile(GHRepository repo) throws IOException {
var fileContent = loadReferenceFileContent(repo.getUrl().toString());
if (fileContent == null) {
return;
}
var headBranch = repo.getBranch(repo.getDefaultBranch());
String refURL = createBranchIfMissing(repo, BRANCH_PREFIX + reference.meta().branchName(), headBranch.getSHA1());
repo.getFileContent(reference.meta().filePath(), refURL)
Expand Down

0 comments on commit a2f436c

Please sign in to comment.