Re: [JGIT PATCH 19/22] Added the class AddRuleListFactory.
lördagen den 10 maj 2008 15.00.37 skrev Florian Koeberle:
Show 8 quoted lines
> +class AddRuleListFactory {
> + /*
> + * The add command of git 1.5.2.5 behaves a little bit stange: "git add
> + * a/\*z" adds the file "a/b/xyz" but "git add a/x\*" does not.
> + *
> + * The first is parsed as pattern "*z" for whole directory tree "a". The
> + * second is parsed as an path.
> + * Show 15 quoted lines
> + */
> +
> + private static List<String> getRelativePath(File projectDirectory, File file)
> + throws PathNotInProjectDirectoryException, IOException {
> + File currentFile = file.getCanonicalFile();
> + final LinkedList<String> relativePath = new LinkedList<String>();
> + while (!currentFile.equals(projectDirectory)) {
> + relativePath.addFirst(currentFile.getName());
> + currentFile = currentFile.getParentFile();
> + if (currentFile == null) {
> + throw new PathNotInProjectDirectoryException();
> + }
> + }
> + return relativePath;
> + }Would be nice to have this logic in a utility class.
-- robin