本文整理汇总了Java中org.eclipse.jgit.errors.NoWorkTreeException类的典型用法代码示例。如果您正苦于以下问题:Java NoWorkTreeException类的具体用法?Java NoWorkTreeException怎么用?Java NoWorkTreeException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NoWorkTreeException类属于org.eclipse.jgit.errors包,在下文中一共展示了NoWorkTreeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteIfUnversioned
import org.eclipse.jgit.errors.NoWorkTreeException; //导入依赖的package包/类
private void deleteIfUnversioned(DirCache cache, String path, WorkingTreeIterator f, Repository repository, TreeWalk treeWalk) throws IOException, NoWorkTreeException {
if (cache.getEntry(path) == null && // not in index
!f.isEntryIgnored() && // not ignored
!Utils.isFromNested(f.getEntryFileMode().getBits()))
{
File file = new File(repository.getWorkTree().getAbsolutePath() + File.separator + path);
if(file.isDirectory()) {
String[] s = file.list();
if(s != null && s.length > 0) { // XXX is there no better way to find out if empty?
// not empty
return;
}
}
file.delete();
listener.notifyFile(file, treeWalk.getPathString());
}
}
示例2: main
import org.eclipse.jgit.errors.NoWorkTreeException; //导入依赖的package包/类
public static void main(final String[] args) throws NoWorkTreeException,
NoHeadException, IOException, GitAPIException {
if (args.length != 4) {
System.err
.println("Usage <datafile> <prefix> <repositoryDir> <outputFilePrefix>");
System.exit(-1);
}
final SvnToGitMapper mapper = new SvnToGitMapper(args[2]);
final RepentDataParser rdp = new RepentDataParser(new File(args[0]),
mapper.mapSvnToGit(), args[1], new Predicate<Integer>() {
@Override
public boolean test(final Integer t) {
return t > 250;
}
});
final List<Renaming> renamings = rdp.parse();
final Multimap<String, Renaming> renamingsPerSha = mapRenamingsToTargetSha(renamings);
final BindingExtractor be = new BindingExtractor(args[2],
renamingsPerSha);
be.doWalk();
writeJson(args[3], "_variables.json", be.renamedVariablesDatapoints);
writeJson(args[3], "_methoddeclarations.json",
be.renamedMethodDeclarationsDatapoints);
}
示例3: main
import org.eclipse.jgit.errors.NoWorkTreeException; //导入依赖的package包/类
/**
* @param args
* @throws IOException
* @throws GitAPIException
* @throws NoHeadException
* @throws NoWorkTreeException
*/
public static void main(final String[] args) throws IOException,
NoWorkTreeException, NoHeadException, GitAPIException {
if (args.length != 3) {
System.err.println("Usage <datafile> <prefix> <repositoryDir>");
System.exit(-1);
}
final SvnToGitMapper mapper = new SvnToGitMapper(args[2]);
final RepentDataParser rdp = new RepentDataParser(new File(args[0]),
mapper.mapSvnToGit(), args[1], new Predicate<Integer>() {
@Override
public boolean test(final Integer t) {
return t < 250;
}
});
final List<Renaming> renamings = rdp.parse();
for (final Renaming renaming : renamings) {
System.out.println(renaming);
}
System.out.println("Num Renamings: " + renamings.size());
}
示例4: mapSvnToGit
import org.eclipse.jgit.errors.NoWorkTreeException; //导入依赖的package包/类
public BiMap<Integer, String> mapSvnToGit() throws IOException,
NoWorkTreeException, NoHeadException, GitAPIException {
final BiMap<Integer, String> mappings = HashBiMap.create();
final Git repository = GitCommitUtils
.getGitRepository(repositoryDirectory);
for (final RevCommit commit : GitCommitUtils
.getAllCommitsTopological(repository)) {
final String message = commit.getFullMessage();
if (!message.contains("git-svn-id")) {
continue;
}
final Matcher matcher = svnIdMatcher.matcher(message);
matcher.find();
mappings.put(Integer.parseInt(matcher.group(1)), commit.name());
}
return mappings;
}
示例5: extractNewModules
import org.eclipse.jgit.errors.NoWorkTreeException; //导入依赖的package包/类
/**
* Extract newed or removed modules
*
*/
public void extractNewModules() {
Status repositoryStatus = null;
try {
repositoryStatus = git.status().call();
} catch (NoWorkTreeException | GitAPIException e) {
e.printStackTrace();
}
newModules = new TreeMap<String, ChangedFile>();
for (String string : repositoryStatus.getUntrackedFolders()) {
for(ChangedFile file : differences) {
if(file.getPath().lastIndexOf(Constants.SLASH) != -1 && file.getPath().substring(0, file.getPath().lastIndexOf(Constants.SLASH)).equals(string) && !newModules.containsKey(string)) {
ChangedFile changedFile = new ChangedFile(string, TypeChange.UNTRACKED_FOLDERS.name(), git.getRepository().getWorkTree().getAbsolutePath());
if(!newModules.containsKey(string)) {
newModules.put(string, changedFile);
}
break;
}
}
}
}
示例6: getAllBaseCommits
import org.eclipse.jgit.errors.NoWorkTreeException; //导入依赖的package包/类
/**
* Return a list of all the commits in the main branches. Start from HEAD
* and then go back, always choosing the first parent commit, then reverse
* list.
*
* @param git
* @return
* @throws IOException
* @throws NoWorkTreeException
*/
public static List<RevCommit> getAllBaseCommits(final Git git)
throws NoWorkTreeException, IOException {
final List<RevCommit> commitList = Lists.newArrayList();
final AnyObjectId headId = git.getRepository().resolve(Constants.HEAD);
final RevWalk walk = new RevWalk(git.getRepository());
RevCommit currentCommit = walk.parseCommit(checkNotNull(headId));
commitList.add(checkNotNull(currentCommit));
while (currentCommit.getParents().length > 0) {
currentCommit = walk.parseCommit(currentCommit.getParent(0)
.toObjectId());
commitList.add(checkNotNull(currentCommit));
}
Collections.reverse(commitList);
return commitList;
}
示例7: parseStagedTestNames
import org.eclipse.jgit.errors.NoWorkTreeException; //导入依赖的package包/类
@Nullable
private Set<String> parseStagedTestNames() {
try {
final Status status = git.status().call();
final Iterable<String> stagedFileNames = Iterables.concat(
status.getAdded(),
status.getChanged(),
status.getRemoved()
);
return FluentIterable.from(stagedFileNames)
.transform(new Function<String, String>() {
@Nullable
@Override
public String apply(@Nullable final String s) {
return parseTestName(testDefinitionsDirectory, s);
}
})
.filter(Predicates.notNull())
.toSet();
} catch (final GitAPIException | NoWorkTreeException e) {
LOGGER.warn("Failed to call git status", e);
return null;
}
}
示例8: createVersion
import org.eclipse.jgit.errors.NoWorkTreeException; //导入依赖的package包/类
public SemverVersion createVersion(Repository repo, Integer buildNumber, boolean topo)
throws MissingObjectException, IncorrectObjectTypeException, IOException,
NoWorkTreeException, GitAPIException {
if (repo == null) {
throw new SemverGitflowPlugin.VersionApplicationException(
"Project is not in a Git repository. Cannot use semver versioning in a non repository.");
}
TagVersionAndCount latestTagAndCount;
if (topo) {
latestTagAndCount = Tags.getTopoTagVersionAndCount(repo, prefix);
} else {
latestTagAndCount = Tags.getLatestTagVersionAndCount(repo, prefix);
}
String headCommitAbbreviation = GitRepos.getHeadCommitIdAbbreviation(repo);
boolean isDirty = GitRepos.isDirty(repo);
return generateVersion(latestTagAndCount, headCommitAbbreviation, buildNumber, isDirty);
}
示例9: validateUnstable
import org.eclipse.jgit.errors.NoWorkTreeException; //导入依赖的package包/类
private void validateUnstable(String expectedVersion,
int commitCount,
RevCommit headCommit,
Dirty dirty,
String firstModifier)
throws NoWorkTreeException, IOException, GitAPIException {
String headCommitId = headCommit.getId().abbreviate(7).name();
String dirtyText = (dirty == Dirty.YES) ? ".dirty" : "";
String expected = expectedVersion + firstModifier + commitCount + "+g"
+ headCommitId + dirtyText;
SemverVersion version = versionFactory.createVersion(repo, null);
Assert.assertEquals(expected, version.toString());
Integer buildNumber = 123;
String expectedWithBuildNumber = expectedVersion + firstModifier
+ commitCount + "+g" + headCommitId + ".b" + buildNumber
+ dirtyText;
Assert.assertEquals(
expectedWithBuildNumber,
versionFactory.createVersion(repo, buildNumber).toString());
}
示例10: getOutputStream
import org.eclipse.jgit.errors.NoWorkTreeException; //导入依赖的package包/类
/**
* Returns an output stream that writes to this connection.
*
* @return the output stream
*/
@Override
public OutputStream getOutputStream() throws IOException {
if (VersionIdentifier.MINE.equals(currentHost)) {
try {
URL fileContent = FileHelper.getFileURL(path);
return fileContent.openConnection().getOutputStream();
} catch (NoWorkTreeException | NoRepositorySelected e) {
throw new IOException(e);
}
}
throw new IOException("Writing is permitted only in the Working Copy files.");
}
示例11: catch
import org.eclipse.jgit.errors.NoWorkTreeException; //导入依赖的package包/类
protected void refreshStatus() {
try {
//
// Grab our working repository
//
Path repoPath = ((XacmlAdminUI)getUI()).getUserGitPath();
final Git git = Git.open(repoPath.toFile());
//
// Get our status
//
final String base;
Status status;
if (target == null) {
base = ".";
} else {
Path relativePath = repoPath.relativize(Paths.get(target.getPath()));
base = relativePath.toString();
}
if (logger.isDebugEnabled()) {
logger.debug("Status on base: " + base);
}
status = git.status().addPath(base).call();
//
// Pass it to our container
//
this.container.refreshStatus(status);
this.tableChanges.refreshRowCache();
} catch (NoWorkTreeException | IOException | GitAPIException e) {
String error = "Failed to refresh status: " + e.getLocalizedMessage();
logger.error(error);
}
}
示例12: getWorkTree
import org.eclipse.jgit.errors.NoWorkTreeException; //导入依赖的package包/类
@Nonnull
@Override
public File getWorkTree() throws NoWorkTreeException {
if(workTree == null)
throw new NoWorkTreeException();
return workTree;
}
示例13: main
import org.eclipse.jgit.errors.NoWorkTreeException; //导入依赖的package包/类
/**
* @param args
* @throws GitAPIException
* @throws IOException
* @throws NoHeadException
* @throws NoWorkTreeException
*/
public static void main(final String[] args) throws NoWorkTreeException,
NoHeadException, IOException, GitAPIException {
if (args.length != 1) {
System.err.println("Usage <repository>");
System.exit(-1);
}
final SvnToGitMapper mapper = new SvnToGitMapper(args[0]);
System.out.println(mapper.mapSvnToGit());
}
示例14: getWorkingDirFiles
import org.eclipse.jgit.errors.NoWorkTreeException; //导入依赖的package包/类
public ArrayList<RepositoryFile> getWorkingDirFiles() {
// TODO: check if working dir is up to date
ArrayList<RepositoryFile> workingDirFiles = null;
File workingDir;
try {
workingDir = GitHandler.gitRepository.getRepository().getWorkTree();
workingDirFiles = getWorkingDirFilesPath(workingDir);
} catch (NoWorkTreeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return workingDirFiles;
}
示例15: statis
import org.eclipse.jgit.errors.NoWorkTreeException; //导入依赖的package包/类
public Status statis(String ... paths) throws NoWorkTreeException, GitAPIException {
if(git == null)
throw new NoWorkTreeException();
StatusCommand status = git.status();
for(String path:paths) status.addPath(path);
return status.call();
}