org.das2.util.filesystem.GitHubFileSystem

GitHubFileSystem allows GitHub directories to be mounted directly, even though it is not a conventional filesystem with files residing in folders. For example, the file resource README.md found in https://github.com/autoplot/scripts/ is downloaded from https://github.com/autoplot/scripts/blob/master/README.md, with "blob/master/" added to the URL. Likewise directory "demos" is found under "tree/master/". GitHub also introduced a new problem, where dates cannot be used for evaluating file freshness. ETags are now supported in WebFileSystem to provide this functionality. Note, GitHub is slow to update the raw view, so five minutes may pass before a pushed change is visible. See https://sourceforge.net/p/autoplot/bugs/2203/ . This can be resolved by maintaining a local clone of the repo.


createGitHubFileSystem

createGitHubFileSystem( java.net.URI root ) → GitHubFileSystem

create GitLabs instance

Parameters

root - the root

Returns:

the filesystem.

[search for examples] [view on GitHub] [view on old javadoc] [view source]

createGitHubFileSystem( java.net.URI root, int baseOffset ) → GitHubFileSystem

getFileObject

getFileObject( String filename ) → FileObject

Parameters

filename - a String

Returns:

org.das2.util.filesystem.FileObject

[search for examples] [view on GitHub] [view on old javadoc] [view source]


getLocalRoot

getLocalRoot( java.net.URI root ) → File

return the location within the file cache of this GitHub filesystem. TODO: There's something with branches that still needs work. Also the constructor does not use this.

Parameters

root - an URI

Returns:

the directory containing the resource.

[search for examples] [view on GitHub] [view on old javadoc] [view source]


getURI

getURI( String filename ) → URI

Parameters

filename - a String

Returns:

java.net.URI

[search for examples] [view on GitHub] [view on old javadoc] [view source]


getURL

getURL( String filename ) → URL

return the URL for the internal filename

Parameters

filename - internal filename

Returns:

a java.net.URL

[search for examples] [view on GitHub] [view on old javadoc] [view source]


gitHubMapDir

gitHubMapDir( java.net.URI root, String filename ) → URL

github puts directories for each project under "tree/master".

Parameters

root - an URI
filename - a String

Returns:

a java.net.URL

[search for examples] [view on GitHub] [view on old javadoc] [view source]


gitHubMapFile

gitHubMapFile( java.net.URI root, String filename ) → URL

Given the URI, convert this to the link which will download the file. github puts directories for each project under "raw/master".

Parameters

root - an URI
filename - a String

Returns:

Translate:
%{code
 https://abbith.physics.uiowa.edu/jbf/myawesomepublicproject/blob/24dff04b9bcb275d8bfd85b38e0e8b039b21d655/sayAwesome.jy to 
https://abbith.physics.uiowa.edu/jbf/myawesomepublicproject/raw/24dff04b9bcb275d8bfd85b38e0e8b039b21d655/sayAwesome.jy https://github.com/autoplot/app/raw/master/Autoplot/src/resources/badge_ok.png to https://github.com/autoplot/app/master/Autoplot/src/resources/badge_ok.png https://jfaden.net/git/jbfaden/public/blob/master/u/jeremy/2019/20191023/updates.jy https://research-git.uiowa.edu/space-physics/juno/ap-script/master/test/testap.jy to https://research-git.uiowa.edu/space-physics/juno/ap-script/-/raw/master/test/testap.jy https://research-git.uiowa.edu/jbf/testproject/-/blob/master/script/testScript.jy to https://research-git.uiowa.edu/jbf/testproject/master/script/testScript.jy }


[search for examples] [view on GitHub] [view on old javadoc] [view source]


isGithubFileSystem

isGithubFileSystem( String h, String path ) → String

one place that lists the GitHub (GitLab) filesystems.

Parameters

h - the host
path - path to the top of the GitLabs instance.

Returns:

null if it is not a GitHub filesystem, or the initial path otherwise

[search for examples] [view on GitHub] [view on old javadoc] [view source]


listDirectory

listDirectory( String directory ) → String

Parameters

directory - a String

Returns:

java.lang.String[]

[search for examples] [view on GitHub] [view on old javadoc] [view source]


listDirectoryGitlab

listDirectoryGitlab( String directory ) → String

At some point, Gitlab started returning the filename listing in a separate JSON response. TODO: It's impossible to distinguish files from folders. On jfaden.net/git, this API does not work.

Parameters

directory - a String

Returns:

a java.lang.String[]

[search for examples] [view on GitHub] [view on old javadoc] [view source]


strjoin

strjoin( java.lang.String[] c, String delim, int start, int end ) → String

this will be replaced in Java 8.

Parameters

c - a java.lang.String[]
delim - a String
start - positive index, or negative from end.
end - positive index, or negative from end.

Returns:

a String

[search for examples] [view on GitHub] [view on old javadoc] [view source]


toString

toString( ) → String

Returns:

java.lang.String

[search for examples] [view on GitHub] [view on old javadoc] [view source]