本文整理了Java中org.eclipse.jgit.api.Git.rm()
方法的一些代码示例,展示了Git.rm()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Git.rm()
方法的具体详情如下:
包路径:org.eclipse.jgit.api.Git
类名称:Git
方法名:rm
[英]Return a command object to execute a rm command
[中]返回命令对象以执行rm命令
代码示例来源:origin: jphp-group/jphp
@Signature
public void rm(String filePattern, boolean cached) throws GitAPIException {
getWrappedObject()
.rm()
.addFilepattern(filePattern)
.setCached(cached)
.call();
}
代码示例来源:origin: apache/incubator-gobblin
@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);
}
代码示例来源:origin: apache/incubator-gobblin
@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);
}
代码示例来源:origin: apache/incubator-gobblin
@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);
}
代码示例来源:origin: apache/incubator-gobblin
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();
代码示例来源:origin: indeedeng/proctor
@Override
public void delete(File testDefinitionDirectory) throws Exception {
for (File file : testDefinitionDirectory.listFiles()) {
git.rm().addFilepattern(testDefinitionsDirectory + "/" + testDefinitionDirectory.getName()
+ "/" + file.getName()).call();
}
}
代码示例来源:origin: com.indeed/proctor-store-git
@Override
public void delete(File testDefinitionDirectory) throws Exception {
for (File file : testDefinitionDirectory.listFiles()) {
git.rm().addFilepattern(testDefinitionsDirectory + "/" + testDefinitionDirectory.getName()
+ "/" + file.getName()).call();
}
}
代码示例来源:origin: openl-tablets/openl-tablets
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();
}
}
}
}
}
代码示例来源:origin: io.fabric8/fabric-openshift
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();
}
}
}
}
代码示例来源:origin: io.fabric8/fabric-git
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();
}
}
代码示例来源:origin: jboss-fuse/fabric8
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();
}
}
代码示例来源:origin: org.apache.camel/camel-git
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;
}
}
代码示例来源:origin: com.madgag/org.eclipse.jgit.pgm
@Override
protected void run() throws Exception {
RmCommand command = new Git(db).rm();
for (String p : paths)
command.addFilepattern(p);
command.call();
}
代码示例来源:origin: org.apereo.cas/cas-mgmt-support-version-control
/**
* 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();
}
}
代码示例来源:origin: org.testeditor.web/org.testeditor.web.dropwizard.xtext.testing
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);
}
}
代码示例来源:origin: io.hawt/hawtio-git
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;
}
}
代码示例来源:origin: org.wildfly.core/wildfly-server
@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);
}
}
}
代码示例来源:origin: io.fabric8.forge/fabric8-forge-core
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;
}
}
代码示例来源:origin: cfg4j/cfg4j
/**
* 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);
}
}
代码示例来源:origin: addthis/hydra
/**
* 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());
}
}
}
内容来源于网络,如有侵权,请联系作者删除!