Skip to content

Commit 5137e84

Browse files
committed
read blob for all sub-command
1 parent 7b9e073 commit 5137e84

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/storage/GitHubJsonStore.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ protected String getAndModifyJsonString(JsonElement json, String img, String tag
137137
}
138138

139139
public Set<Map.Entry<String, JsonElement>> parseStoreToImagesMap(DockerfileGitHubUtil dockerfileGitHubUtil, String storeName)
140-
throws IOException, InterruptedException {
140+
throws IOException {
141141
GHMyself myself = dockerfileGitHubUtil.getMyself();
142142
String login = myself.getLogin();
143143
GHRepository store = dockerfileGitHubUtil.getRepo(Paths.get(login, storeName).toString());
144144

145-
GHContent storeContent = dockerfileGitHubUtil.tryRetrievingContent(store, Constants.STORE_JSON_FILE,
145+
GHBlob storeContent = dockerfileGitHubUtil.tryRetrievingBlob(store, Constants.STORE_JSON_FILE,
146146
store.getDefaultBranch());
147147

148148
if (storeContent == null) {
@@ -163,7 +163,7 @@ public Set<Map.Entry<String, JsonElement>> parseStoreToImagesMap(DockerfileGitHu
163163
return imagesJson.getAsJsonObject().entrySet();
164164
}
165165

166-
public List<ImageTagStoreContent> getStoreContent(DockerfileGitHubUtil dockerfileGitHubUtil, String storeName) throws IOException, InterruptedException {
166+
public List<ImageTagStoreContent> getStoreContent(DockerfileGitHubUtil dockerfileGitHubUtil, String storeName) throws IOException {
167167
Set<Map.Entry<String, JsonElement>> imageToTagStore = parseStoreToImagesMap(dockerfileGitHubUtil, storeName);
168168
return imageToTagStore.stream()
169169
.map(entry -> new ImageTagStoreContent(entry.getKey(), entry.getValue().getAsString()))

dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/storage/S3BackedImageTagStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public List<ImageTagStoreContent> getStoreContent(DockerfileGitHubUtil dockerfil
6969
return imageNamesWithTag;
7070
}
7171

72-
private List<ImageTagStoreContent> getStoreContentSortedByAccessDate(Map<String, Date> imageNameWithAccessTime) throws InterruptedException {
72+
private List<ImageTagStoreContent> getStoreContentSortedByAccessDate(Map<String, Date> imageNameWithAccessTime) {
7373
List<ImageTagStoreContent> imageNameWithTagSortedByAccessDate = new ArrayList<>();
7474
LinkedHashMap<String, Date> sortedResult = new LinkedHashMap<>();
7575
// Sort the content by the access date so that the file which was accessed most recently gets processed first

dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/utils/DockerfileGitHubUtil.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ public GHContent tryRetrievingContent(GHRepository repo, String path, String bra
257257
return gitHubUtil.tryRetrievingContent(repo, path, branch);
258258
}
259259

260+
public GHBlob tryRetrievingBlob(GHRepository repo, String path, String branch) throws IOException {
261+
return gitHubUtil.tryRetrievingBlob(repo, path, branch);
262+
}
263+
260264
public void modifyOnGithub(GHContent content,
261265
String branch, String img, String tag,
262266
String customMessage, String ignoreImageString) throws IOException {

dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/utils/GitHubUtil.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ public GHContent tryRetrievingContent(GHRepository repo, String path, String bra
196196
return content;
197197
}
198198

199+
public GHBlob tryRetrievingBlob(GHRepository repo, String path, String branch) throws IOException {
200+
return repo.getCommit(branch).getTree().getEntry(path).asBlob();
201+
}
202+
199203
/* Workaround: The GitHub API caches API calls for up to 60 seconds, so back-to-back API calls with the same
200204
* command will return the same thing. i.e. the above command listRepositories will return the same output if
201205
* this tool is invoked twice in a row, even though it should return different lists, because of the new forks.

0 commit comments

Comments
 (0)