-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MARP-1451 include codeowners in GitHub for each connector (#2)
* Added Codeowner detecter * Define codeowner for market * Add gitignore * Remove unuse file * Format codes * Enhance log file * Handle feedback * Handle permission
- Loading branch information
1 parent
96c474b
commit f6a45d2
Showing
11 changed files
with
207 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Default ignored files | ||
/shelf/ | ||
/workspace.xml | ||
./idea/* | ||
*/idea/* |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
github-repo-manager/src/main/java/com/axonivy/github/file/CodeOwnerFilesDetector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.axonivy.github.file; | ||
|
||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.apache.commons.lang3.ObjectUtils; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
public class CodeOwnerFilesDetector extends GitHubMissingFilesDetector { | ||
private static final String CODE_OWNER_FILE_NAME = "CodeOwners.json"; | ||
private static final TypeReference<List<CodeOwner>> CODE_OWNER_TYPE_REFERENCE = new TypeReference<>() { | ||
}; | ||
private static final String CODE_OWNER_FORMAT = "* %s"; | ||
private static final ObjectMapper objectMapper = new ObjectMapper(); | ||
private List<CodeOwner> codeOwners; | ||
|
||
public CodeOwnerFilesDetector(GitHubFiles.FileMeta fileMeta, String user) throws IOException { | ||
super(fileMeta, user); | ||
} | ||
|
||
@Override | ||
protected byte[] loadReferenceFileContent(String repoURL) throws IOException { | ||
if (StringUtils.isBlank(repoURL)) { | ||
return super.loadReferenceFileContent(repoURL); | ||
} | ||
|
||
for (var codeOwner : getAllCodeOwners()) { | ||
if (StringUtils.contains(repoURL, codeOwner.product)) { | ||
return String.format(CODE_OWNER_FORMAT, codeOwner.owner).getBytes(); | ||
} | ||
} | ||
return new byte[0]; | ||
} | ||
|
||
private List<CodeOwner> getAllCodeOwners() throws IOException { | ||
if (ObjectUtils.isEmpty(codeOwners)) { | ||
try (var is = CodeOwnerFilesDetector.class.getResourceAsStream(CODE_OWNER_FILE_NAME)) { | ||
codeOwners = objectMapper.readValue(is, CODE_OWNER_TYPE_REFERENCE); | ||
} | ||
} | ||
return codeOwners; | ||
} | ||
|
||
record CodeOwner(String product, String owner) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.