@Signature public void rm(String filePattern, boolean cached) throws GitAPIException { getWrappedObject() .rm() .addFilepattern(filePattern) .setCached(cached) .call(); }
@Test (dependsOnMethods = "testUpdateNode") public void testRemoveEdge() throws GitAPIException, IOException { // delete a config file edge1File.delete(); //Node1 has 1 edge before delete Set<FlowEdge> edgeSet = this.flowGraph.getEdges("node1"); Assert.assertEquals(edgeSet.size(), 1); // delete, commit, push DirCache ac = this.gitForPush.rm().addFilepattern(formEdgeFilePath(this.edge1Dir.getParentFile().getName(), this.edge1Dir.getName(), this.edge1File.getName())).call(); RevCommit cc = this.gitForPush.commit().setMessage("Edge remove commit").call(); this.gitForPush.push().setRemote("origin").setRefSpecs(this.masterRefSpec).call(); this.gitFlowGraphMonitor.processGitConfigChanges(); //Check if edge1 has been deleted from the graph edgeSet = this.flowGraph.getEdges("node1"); Assert.assertTrue(edgeSet.size() == 0); }
@Test(dependsOnMethods = "testUpdateConfig") public void testDeleteConfig() throws IOException, GitAPIException, URISyntaxException { // delete a config file testFlowFile.delete(); // flow catalog has 1 entry before the config is deleted Collection<Spec> specs = this.flowCatalog.getSpecs(); Assert.assertTrue(specs.size() == 1); // add, commit, push DirCache ac = this.gitForPush.rm().addFilepattern(formConfigFilePath(this.testGroupDir.getName(), this.testFlowFile.getName())) .call(); RevCommit cc = this.gitForPush.commit().setMessage("Fourth commit").call(); this.gitForPush.push().setRemote("origin").setRefSpecs(this.masterRefSpec).call(); this.gitConfigMonitor.processGitConfigChanges(); specs = this.flowCatalog.getSpecs(); Assert.assertTrue(specs.size() == 0); }
@Test (dependsOnMethods = "testRemoveEdge") public void testRemoveNode() throws GitAPIException, IOException { //delete node files node1File.delete(); node2File.delete(); //Ensure node1 and node2 are present in the graph before delete DataNode node1 = this.flowGraph.getNode("node1"); Assert.assertNotNull(node1); DataNode node2 = this.flowGraph.getNode("node2"); Assert.assertNotNull(node2); // delete, commit, push this.gitForPush.rm().addFilepattern(formNodeFilePath(this.node1Dir.getName(), this.node1File.getName())).call(); this.gitForPush.rm().addFilepattern(formNodeFilePath(this.node2Dir.getName(), this.node2File.getName())).call(); this.gitForPush.commit().setMessage("Node remove commit").call(); this.gitForPush.push().setRemote("origin").setRefSpecs(this.masterRefSpec).call(); this.gitFlowGraphMonitor.processGitConfigChanges(); //Check if node1 and node 2 have been deleted from the graph node1 = this.flowGraph.getNode("node1"); Assert.assertNull(node1); node2 = this.flowGraph.getNode("node2"); Assert.assertNull(node2); }
this.gitForPush.rm().addFilepattern(formNodeFilePath(this.node1Dir.getName(), this.node1File.getName())).call(); this.gitForPush.rm().addFilepattern(formEdgeFilePath(this.edge1Dir.getParentFile().getName(), this.edge1Dir.getName(), this.edge1File.getName())).call(); this.gitForPush.commit().setMessage("Delete node1 and edge1 commit").call(); this.gitForPush.push().setRemote("origin").setRefSpecs(this.masterRefSpec).call();
@Override public void delete(File testDefinitionDirectory) throws Exception { for (File file : testDefinitionDirectory.listFiles()) { git.rm().addFilepattern(testDefinitionsDirectory + "/" + testDefinitionDirectory.getName() + "/" + file.getName()).call(); } }
@Override public void delete(File testDefinitionDirectory) throws Exception { for (File file : testDefinitionDirectory.listFiles()) { git.rm().addFilepattern(testDefinitionsDirectory + "/" + testDefinitionDirectory.getName() + "/" + file.getName()).call(); } }
private void removeAbsentFiles(String baseAbsolutePath, File directory, Collection<File> toSave) throws GitAPIException { File[] found = directory.listFiles(); if (found != null) { for (File file : found) { if (file.isDirectory()) { removeAbsentFiles(baseAbsolutePath, file, toSave); } else { if (!toSave.contains(file)) { String relativePath = file.getAbsolutePath().substring(baseAbsolutePath.length()).replace('\\', '/'); if (relativePath.startsWith("/")) { relativePath = relativePath.substring(1); } git.rm().addFilepattern(relativePath).call(); } } } } }
protected void deleteFiles(Git git, File baseDir, String path, List<String> fileNames) throws GitAPIException { if (path != null) { for (String fileName : fileNames) { File file = new File(baseDir, path + "/" + fileName); if (file.exists()) { LOG.debug("Removing " + file + " for container " + container.getId()); git.rm().addFilepattern(path + "/" + fileName).call(); file.delete(); } } } }
private void recursiveDeleteAndRemove(Git git, File file) throws IOException, GitAPIException { File rootDir = GitHelpers.getRootGitDirectory(git); String relativePath = getFilePattern(rootDir, file); if (file.exists() && !relativePath.equals(".git")) { if (file.isDirectory()) { File[] files = file.listFiles(); if (files != null) { for (File child : files) { recursiveDeleteAndRemove(git, child); } } } file.delete(); git.rm().addFilepattern(relativePath).call(); } }
private void recursiveDeleteAndRemove(Git git, File file) throws IOException, GitAPIException { File rootDir = GitHelpers.getRootGitDirectory(git); String relativePath = getFilePattern(rootDir, file); if (file.exists() && !relativePath.equals(".git")) { if (file.isDirectory()) { File[] files = file.listFiles(); if (files != null) { for (File child : files) { recursiveDeleteAndRemove(git, child); } } } file.delete(); git.rm().addFilepattern(relativePath).call(); } }
protected void doRemove(Exchange exchange, String operation) throws Exception { String fileName = null; if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME))) { fileName = exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME, String.class); } else { throw new IllegalArgumentException("File name must be specified to execute " + operation); } try { if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) { git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call(); } git.rm().addFilepattern(fileName).call(); } catch (Exception e) { LOG.error("There was an error in Git {} operation", operation); throw e; } }
@Override protected void run() throws Exception { RmCommand command = new Git(db).rm(); for (String p : paths) command.addFilepattern(p); command.call(); }
/** * Rm. * * @param newPath the new path * @throws GitAPIException the exception */ public void rm(final String newPath) throws GitAPIException { if (!isUndefined()) { git.rm().addFilepattern(newPath).call(); } }
protected RevCommit deleteOnRemote(final String file) { try { File _root = this.remoteRepoTemporaryFolder.getRoot(); final File fileToDelete = new File(_root, file); fileToDelete.delete(); this.remoteGit.rm().addFilepattern(file).call(); return this.remoteGit.commit().setMessage(("Delete " + file)).call(); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
protected RevCommit doRemove(Git git, File rootDir, String branch, String path, String commitMessage, PersonIdent personIdent) throws Exception { File file = getFile(rootDir, path); if (file.exists()) { Files.recursiveDelete(file); String filePattern = getFilePattern(path); git.rm().addFilepattern(filePattern).call(); CommitCommand commit = git.commit().setAll(true).setAuthor(personIdent).setMessage(commitMessage); return commitThenPush(git, branch, commit); } else { return null; } }
@Override public void removeContent(ContentReference reference) { final Path realFile = getDeploymentContentFile(reference.getHash()); super.removeContent(reference); if (!Files.exists(realFile)) { try (Git git = gitRepository.getGit()) { Set<String> deletedFiles = git.status().call().getMissing(); RmCommand rmCommand = git.rm(); for (String file : deletedFiles) { rmCommand.addFilepattern(file); } rmCommand.addFilepattern(gitRepository.getPattern(realFile)).call(); } catch (GitAPIException ex) { throw new RuntimeException(ex); } } }
protected CommitInfo doRemove(Git git, String path) throws Exception { File file = getRelativeFile(path); if (file.exists()) { Files.recursiveDelete(file); String filePattern = getFilePattern(path); git.rm().addFilepattern(filePattern).call(); CommitCommand commit = git.commit().setAll(true).setAuthor(personIdent).setMessage(message); return createCommitInfo(commitThenPush(git, commit)); } else { return null; } }
/** * Delete file from this repository. Commits changes. * * @param filePath relative file path to delete * @throws GitAPIException when unable to commit changes */ @Override public void deleteFile(Path filePath) throws IOException { try { super.deleteFile(filePath); repo.rm() .addFilepattern(filePath.toString()) .call(); commitChanges(); } catch (GitAPIException e) { throw new IOException(e); } }
/** * Delete a config and remove it from git tracking * * @param jobId The job config to remove */ public void remove(String jobId) { File file = getFileForJobId(jobId); synchronized (gitDir) { try { git.rm().addFilepattern(getPathForJobId(jobId)).call(); git.commit().setMessage(getDeleteCommitMessage(jobId)).call(); push(); } catch (Exception e) { // Maybe the file hadn't been committed yet, or was not tracked in the first place assert (file.delete()); } } }