本文整理汇总了Java中org.eclipse.jgit.util.FileUtils.delete方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.delete方法的具体用法?Java FileUtils.delete怎么用?Java FileUtils.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.util.FileUtils
的用法示例。
在下文中一共展示了FileUtils.delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clone
import org.eclipse.jgit.util.FileUtils; //导入方法依赖的package包/类
@Override
public File clone(String branch, Set<String> checkoutFiles, ProgressMonitor monitor) throws GitException {
checkGitUrl();
File gitDir = getGitPath().toFile();
// delete existing git folder since may have conflict
if (gitDir.exists()) {
try {
FileUtils.delete(gitDir.getParentFile(), FileUtils.RECURSIVE);
} catch (IOException e) {
// IO error on delete existing folder
}
}
// git init
initGit(checkoutFiles);
pull(branch, monitor);
return gitDir;
}
示例2: deleteFS
import org.eclipse.jgit.util.FileUtils; //导入方法依赖的package包/类
private boolean deleteFS(final FileSystem fileSystem) {
final File gitDir = ((JGitFileSystemImpl) fileSystem).getGit().getRepository().getDirectory();
fileSystem.close();
fileSystem.dispose();
try {
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
//this operation forces a cache clean freeing any lock -> windows only issue!
WindowCache.reconfigure(new WindowCacheConfig());
}
FileUtils.delete(gitDir,
FileUtils.RECURSIVE | FileUtils.RETRY);
return true;
} catch (java.io.IOException e) {
throw new IOException("Failed to remove the git repository.",
e);
}
}
示例3: deleteRepository
import org.eclipse.jgit.util.FileUtils; //导入方法依赖的package包/类
/**
* Deletes the repository from the file system and removes the repository
* permission from all repository users.
*
* @param repositoryName
* @return true if successful
*/
public boolean deleteRepository(String repositoryName) {
try {
closeRepository(repositoryName);
// clear the repository cache
clearRepositoryMetadataCache(repositoryName);
RepositoryModel model = removeFromCachedRepositoryList(repositoryName);
if (model != null && !ArrayUtils.isEmpty(model.forks)) {
resetRepositoryListCache();
}
File folder = new File(repositoriesFolder, repositoryName);
if (folder.exists() && folder.isDirectory()) {
FileUtils.delete(folder, FileUtils.RECURSIVE | FileUtils.RETRY);
if (userService.deleteRepositoryRole(repositoryName)) {
logger.info(MessageFormat.format("Repository \"{0}\" deleted", repositoryName));
return true;
}
}
} catch (Throwable t) {
logger.error(MessageFormat.format("Failed to delete repository {0}", repositoryName), t);
}
return false;
}
示例4: testAnonymousClone
import org.eclipse.jgit.util.FileUtils; //导入方法依赖的package包/类
@Test
public void testAnonymousClone() throws Exception {
GitBlitSuite.close(ticgitFolder);
if (ticgitFolder.exists()) {
FileUtils.delete(ticgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY);
}
// set push restriction
RepositoryModel model = GitBlit.self().getRepositoryModel("ticgit.git");
model.accessRestriction = AccessRestrictionType.PUSH;
model.authorizationControl = AuthorizationControl.NAMED;
GitBlit.self().updateRepositoryModel(model.name, model, false);
CloneCommand clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
clone.setDirectory(ticgitFolder);
clone.setBare(false);
clone.setCloneAllBranches(true);
GitBlitSuite.close(clone.call());
assertTrue(true);
// restore anonymous repository access
model.accessRestriction = AccessRestrictionType.NONE;
model.authorizationControl = AuthorizationControl.NAMED;
GitBlit.self().updateRepositoryModel(model.name, model, false);
}
示例5: testCreateRepository
import org.eclipse.jgit.util.FileUtils; //导入方法依赖的package包/类
@Test
public void testCreateRepository() throws Exception {
String[] repositories = { "NewTestRepository.git", "NewTestRepository" };
for (String repositoryName : repositories) {
Repository repository = JGitUtils.createRepository(GitBlitSuite.REPOSITORIES,
repositoryName);
File folder = FileKey.resolve(new File(GitBlitSuite.REPOSITORIES, repositoryName),
FS.DETECTED);
assertNotNull(repository);
assertFalse(JGitUtils.hasCommits(repository));
assertNull(JGitUtils.getFirstCommit(repository, null));
assertEquals(folder.lastModified(), JGitUtils.getFirstChange(repository, null)
.getTime());
assertEquals(folder.lastModified(), JGitUtils.getLastChange(repository).getTime());
assertNull(JGitUtils.getCommit(repository, null));
repository.close();
RepositoryCache.close(repository);
FileUtils.delete(repository.getDirectory(), FileUtils.RECURSIVE);
}
}
示例6: deleteWorkingFolders
import org.eclipse.jgit.util.FileUtils; //导入方法依赖的package包/类
public static void deleteWorkingFolders() throws Exception {
if (ticgitFolder.exists()) {
GitBlitSuite.close(ticgitFolder);
FileUtils.delete(ticgitFolder, FileUtils.RECURSIVE);
}
if (ticgit2Folder.exists()) {
GitBlitSuite.close(ticgit2Folder);
FileUtils.delete(ticgit2Folder, FileUtils.RECURSIVE);
}
if (jgitFolder.exists()) {
GitBlitSuite.close(jgitFolder);
FileUtils.delete(jgitFolder, FileUtils.RECURSIVE);
}
if (jgit2Folder.exists()) {
GitBlitSuite.close(jgit2Folder);
FileUtils.delete(jgit2Folder, FileUtils.RECURSIVE);
}
}
示例7: testClone
import org.eclipse.jgit.util.FileUtils; //导入方法依赖的package包/类
@Test
public void testClone() throws Exception {
GitBlitSuite.close(ticgitFolder);
if (ticgitFolder.exists()) {
FileUtils.delete(ticgitFolder, FileUtils.RECURSIVE | FileUtils.RETRY);
}
CloneCommand clone = Git.cloneRepository();
clone.setURI(MessageFormat.format("{0}/ticgit.git", url));
clone.setDirectory(ticgitFolder);
clone.setBare(false);
clone.setCloneAllBranches(true);
clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider(account, password));
GitBlitSuite.close(clone.call());
assertTrue(true);
}
示例8: deleteBaseDirIfExists
import org.eclipse.jgit.util.FileUtils; //导入方法依赖的package包/类
private void deleteBaseDirIfExists() {
if (this.basedir.exists()) {
try {
FileUtils.delete(this.basedir, FileUtils.RECURSIVE);
}
catch (IOException e) {
throw new IllegalStateException("Failed to initialize base directory", e);
}
}
}
示例9: prepareLocalRepo
import org.eclipse.jgit.util.FileUtils; //导入方法依赖的package包/类
private static void prepareLocalRepo(String buildDir, String repoPath) throws IOException {
File dotGit = new File(buildDir + repoPath + "/.git");
File git = new File(buildDir + repoPath + "/git");
if (git.exists()) {
if (dotGit.exists()) {
FileUtils.delete(dotGit, FileUtils.RECURSIVE);
}
}
git.renameTo(dotGit);
}
示例10: tryDeleteRepository
import org.eclipse.jgit.util.FileUtils; //导入方法依赖的package包/类
public static void tryDeleteRepository(String remoteUrl) {
RepositoryCache repositoryCache = Activator.getDefault().getRepositoryCache();
Repository[] repositories = repositoryCache.getAllRepositories();
for (Repository repository : repositories) {
if (getRemotesUrls(repository).contains(remoteUrl)) {
try {
FileUtils.delete(repository.getDirectory(),
FileUtils.RECURSIVE | FileUtils.RETRY | FileUtils.SKIP_MISSING);
FileUtils.delete(repository.getWorkTree(),
FileUtils.RECURSIVE | FileUtils.RETRY | FileUtils.SKIP_MISSING);
} catch (IOException e) {
}
}
}
}
示例11: closeRepository
import org.eclipse.jgit.util.FileUtils; //导入方法依赖的package包/类
@After
public void closeRepository() throws IOException {
if(repo != null)
repo.close();
if(repoDir != null && repoDir.exists())
FileUtils.delete(repoDir, FileUtils.RECURSIVE);
}
示例12: deleteRepositoryFolder
import org.eclipse.jgit.util.FileUtils; //导入方法依赖的package包/类
private void deleteRepositoryFolder() {
try {
if (repository.getDirectory().exists()) {
FileUtils.delete(repository.getDirectory(), FileUtils.RECURSIVE | FileUtils.IGNORE_ERRORS);
}
} catch (Exception exception) {
// Ignore the error since we want to throw the original error
LOG.error(
"Could not remove .git folder in path " + repository.getDirectory().getPath(), exception);
}
}
示例13: destroyGitFsProvider
import org.eclipse.jgit.util.FileUtils; //导入方法依赖的package包/类
@After
public void destroyGitFsProvider() throws IOException {
if (provider == null) {
// this would mean that setup failed. no need to clean up.
return;
}
provider.shutdown();
if (provider.getGitRepoContainerDir() != null && provider.getGitRepoContainerDir().exists()) {
FileUtils.delete(provider.getGitRepoContainerDir(),
FileUtils.RECURSIVE);
}
}
示例14: cleanup
import org.eclipse.jgit.util.FileUtils; //导入方法依赖的package包/类
@AfterClass
@BeforeClass
public static void cleanup() {
for (final File tempFile : tempFiles) {
try {
FileUtils.delete(tempFile,
FileUtils.RECURSIVE);
} catch (IOException e) {
}
}
}
示例15: deleteBaseDirIfExists
import org.eclipse.jgit.util.FileUtils; //导入方法依赖的package包/类
private void deleteBaseDirIfExists() {
if (getBasedir().exists()) {
for (File file : getBasedir().listFiles()) {
try {
FileUtils.delete(file, FileUtils.RECURSIVE);
}
catch (IOException e) {
throw new IllegalStateException("Failed to initialize base directory",
e);
}
}
}
}