## 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 ) → org.das2.util.filesystem.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 ) → org.das2.util.filesystem.GitHubFileSystem [view source]

## detectForge

detectForge( java.net.URI root ) → org.das2.util.filesystem.GitHubFileSystem.Forge

detect if the URI is a GitHub or GitLab instance. This presently looks for github.com or gitlab.umn.edu.

### Parameters

root - an URI

### Returns:

Forge value.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getDefaultBranch

getDefaultBranch( java.net.URI root, String project ) → String

return the default branch (e.g. master or main) for the repo

### Parameters

root - an URI
project - a String

### Returns:

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

## getDefaultBranchGitHub

getDefaultBranchGitHub( java.net.URI root, String project ) → String

Return the default branch (e.g. main or master) for the project.

### Parameters

root - the GitHub root (e.g. https://github.com/autoplot/)
project - the project (e.g. 'autoplot/dev')

### Returns:

the default branch (e.g. 'master')
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getDefaultBranchGitLab

getDefaultBranchGitLab( java.net.URI root, String project ) → String

Return the default branch (e.g. main or master) for the project.

### Parameters

root - the GitLab root (e.g. https://research-git.uiowa.edu/)
project - the project (e.g. 'space-physics/rbsp/ap-script')

### Returns:

the default branch (e.g. 'master')
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getFileObject

getFileObject( String filename ) → org.das2.util.filesystem.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 ) → java.io.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 ) → java.net.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 ) → java.net.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 ) → java.net.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 ) → java.net.URL

Given the URI, convert this to the link which will download the file. github puts directories for each project under "raw/master". TODO: verify this works (I don't think it will) when filename contains slash.

### Parameters

root - the Das2 FileSystem root, which can be a directory within a repo.
filename - the filename to download, not containing any slashes.

### Returns:

the URL to download the file.

### See Also:

https://github.com/autoplot/dev/blob/master/bugs/ghdas2/demo173.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[]

Use GitLab's API to list the directory. For example, https://research-git.uiowa.edu/space-physics/rbsp/ap-script/-/tree/master/u/ivar/20210416/ should list the files in this directory, using calls like https://research-git.uiowa.edu/api/v4/projects/space-physics%2Frbsp%2Fap-script/repository/tree?path=u/ivar/20210416/&ref=master which will return a JSON listing.

### Parameters

directory - within the filesystem

### Returns:

the list of files, with / suffix for directories.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## listDirectoryGitLabHowever

listDirectoryGitLabHowever( 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.

### Parameters

directory - a String

### Returns:

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

## listDirectoryGithub

listDirectoryGithub( String directory ) → String[]

Use GitHub's API to list the directory.

### Parameters

directory - within the filesystem

### Returns:

the list of files, with / suffix for directories.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## strjoin

strjoin( 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]