public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage) throws IOException { return update(newContentBytes, commitMessage, null); }
public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage) throws IOException { return update(newContentBytes, commitMessage, null); }
public GHContentUpdateResponse update(byte[] newContentBytes, String commitMessage) throws IOException { return update(newContentBytes, commitMessage, null); }
public GHContentUpdateResponse update(String newContent, String commitMessage) throws IOException { return update(newContent.getBytes(), commitMessage, null); }
public GHContentUpdateResponse update(String newContent, String commitMessage, String branch) throws IOException { return update(newContent.getBytes(), commitMessage, branch); }
@SuppressFBWarnings("DM_DEFAULT_ENCODING") public GHContentUpdateResponse update(String newContent, String commitMessage, String branch) throws IOException { return update(newContent.getBytes(), commitMessage, branch); }
@SuppressFBWarnings("DM_DEFAULT_ENCODING") public GHContentUpdateResponse update(String newContent, String commitMessage) throws IOException { return update(newContent.getBytes(), commitMessage, null); }
@SuppressFBWarnings("DM_DEFAULT_ENCODING") public GHContentUpdateResponse update(String newContent, String commitMessage, String branch) throws IOException { return update(newContent.getBytes(), commitMessage, branch); }
@SuppressFBWarnings("DM_DEFAULT_ENCODING") public GHContentUpdateResponse update(String newContent, String commitMessage) throws IOException { return update(newContent.getBytes(), commitMessage, null); }
/** * Changes content of the file * * @param pathToFile path to specified file * @param content content to change * @param commitMessage message to commit * @throws IOException */ public void changeFileContent(String pathToFile, String content, String commitMessage) throws IOException { ghRepo.getFileContent(String.format("/%s", pathToFile)).update(content, commitMessage); }
protected void findImagesAndFix(GHContent content, String branch, String img, String tag, String customMessage, BufferedReader reader) throws IOException { StringBuilder strB = new StringBuilder(); boolean modified = rewriteDockerfile(img, tag, reader, strB); if (modified) { content.update(strB.toString(), "Fix Dockerfile base image in /" + content.getPath() + "\n\n" + customMessage, branch); } }
protected void findImagesAndFix(GHContent content, String branch, String img, String tag, String customMessage, BufferedReader reader) throws IOException { StringBuilder strB = new StringBuilder(); boolean modified = rewriteDockerfile(img, tag, reader, strB); if (modified) { content.update(strB.toString(), "Fix Dockerfile base image in /" + content.getPath() + "\n\n" + customMessage, branch); } }
protected void updateStoreOnGithub(GHRepository repo, String path, String img, String tag) throws IOException { try { repo.getFileContent(path); } catch (IOException e) { repo.createContent("", "initializing store", path); } String latestCommit = repo.getBranches().get(repo.getDefaultBranch()).getSHA1(); log.info("Loading image store at commit {}", latestCommit); GHContent content = repo.getFileContent(path, latestCommit); if (content.isFile()) { JsonElement json; try (InputStream stream = content.read(); InputStreamReader streamR = new InputStreamReader(stream)) { try { json = new JsonParser().parse(streamR); } catch (JsonParseException e) { log.warn("Not a JSON format store. Clearing and rewriting as JSON..."); json = JsonNull.INSTANCE; } } String jsonOutput = getAndModifyJsonString(json, img, tag); content.update(jsonOutput, String.format("Updated image %s with tag %s.\n@rev none@", img, tag), repo.getDefaultBranch()); } }
protected void updateStoreOnGithub(GHRepository repo, String path, String img, String tag) throws IOException { try { repo.getFileContent(path); } catch (IOException e) { repo.createContent("", "initializing store", path); } String latestCommit = repo.getBranches().get(repo.getDefaultBranch()).getSHA1(); log.info("Loading image store at commit {}", latestCommit); GHContent content = repo.getFileContent(path, latestCommit); if (content.isFile()) { JsonElement json; try (InputStream stream = content.read(); InputStreamReader streamR = new InputStreamReader(stream)) { try { json = new JsonParser().parse(streamR); } catch (JsonParseException e) { log.warn("Not a JSON format store. Clearing and rewriting as JSON..."); json = JsonNull.INSTANCE; } } String jsonOutput = getAndModifyJsonString(json, img, tag); content.update(jsonOutput, String.format("Updated image %s with tag %s.\n@rev none@", img, tag), repo.getDefaultBranch()); } }
/** * Creates ".gitmodules" file or updates if it already exist. * * @see <a href="https://git-scm.com/docs/gitmodules">gitmodules </a> */ private void setupSubmoduleConfig(TestGitHubRepository submodule, String pathToSubmoduleContent) throws IOException { final String gitmodulesFileName = ".gitmodules"; String submoduleConfig = getSubmoduleConfig(submodule, pathToSubmoduleContent); if (isGitmodulesFileExist()) { GHContent submoduleFileContent = ghRepo.getFileContent(gitmodulesFileName); String newFileContent = getFileContent(gitmodulesFileName) + "\n" + submoduleConfig; submoduleFileContent.update(newFileContent, "Update " + gitmodulesFileName); return; } ghRepo.createContent(submoduleConfig, "Add " + gitmodulesFileName, gitmodulesFileName); }