Skip to content

Commit

Permalink
Fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
sralmai committed Jan 2, 2015
1 parent f9e39a0 commit 9080d85
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,16 @@ private boolean isFile( String file )
return targetFile.isFile();
}

protected static String resolvePath(String fileEntry, URI path) {
protected static String resolvePath( String fileEntry, URI path )
{
/* Quotes may be included (from the git status line) when an fileEntry includes spaces */
String cleanedEntry = stripQuotes(fileEntry);
if (path != null) {
return resolveURI(cleanedEntry, path).getPath();
} else {
String cleanedEntry = stripQuotes( fileEntry );
if ( path != null )
{
return resolveURI( cleanedEntry, path ).getPath();
}
else
{
return cleanedEntry;
}
}
Expand All @@ -243,7 +247,7 @@ public static URI resolveURI( String fileEntry, URI path )
// When using URI.create, spaces need to be escaped but not the slashes, so we can't use
// URLEncoder.encode( String, String )
// new File( String ).toURI() results in an absolute URI while path is relative, so that can't be used either.
return path.relativize(URI.create(stripQuotes(fileEntry).replace(" ", "%20")));
return path.relativize( URI.create( stripQuotes( fileEntry ).replace( " ", "%20" ) ) );
}


Expand All @@ -256,8 +260,9 @@ public List<ScmFile> getChangedFiles()
* @param str the (potentially quoted) string, must not be {@code null}
* @return the string with a pair of double quotes removed (if they existed)
*/
private static String stripQuotes(String str) {
private static String stripQuotes( String str )
{
int strLen = str.length();
return (strLen > 0 && str.startsWith("\"") && str.endsWith("\"")) ? str.substring(1, strLen - 1) : str;
return ( strLen > 0 && str.startsWith( "\"" ) && str.endsWith( "\"" ) ) ? str.substring( 1, strLen - 1 ) : str;
}
}

0 comments on commit 9080d85

Please sign in to comment.