fileContents,_:=GetContents(ctx,repo,refCommit,treePath,false)// ok if fails, then will be nil
fileContents,_:=GetFileContents(ctx,repo,gitRepo,refCommit,GetContentsOrListOptions{TreePath:treePath,IncludeSingleFileContent:true})// ok if fails, then will be nil
"description": "It guarantees that only one of the response fields is set if the request succeeds. Users can pass \"includes=file_content\" or \"includes=lfs_metadata\" to retrieve more fields.",
"produces": [
"application/json"
],
"tags": [
"repository"
],
"summary": "The extended \"contents\" API, to get file metadata and/or content, or list a directory.",
"operationId": "repoGetContentsExt",
"parameters": [
{
"type": "string",
"description": "owner of the repo",
"name": "owner",
"in": "path",
"required": true
},
{
"type": "string",
"description": "name of the repo",
"name": "repo",
"in": "path",
"required": true
},
{
"type": "string",
"description": "path of the dir, file, symlink or submodule in the repo",
"name": "filepath",
"in": "path",
"required": true
},
{
"type": "string",
"description": "the name of the commit/branch/tag, default to the repository’s default branch.",
"name": "ref",
"in": "query"
},
{
"type": "string",
"description": "By default this API's response only contains file's metadata. Use comma-separated \"includes\" options to retrieve more fields. Option \"file_content\" will try to retrieve the file content, option \"lfs_metadata\" will try to retrieve LFS metadata.",
"name": "includes",
"in": "query"
}
],
"responses": {
"200": {
"$ref": "#/responses/ContentsExtResponse"
},
"404": {
"$ref": "#/responses/notFound"
}
}
}
},
"/repos/{owner}/{repo}/contents/{filepath}": {
"get": {
"description": "This API follows GitHub's design, and it is not easy to use. Recommend to use our \"contents-ext\" API instead.",
"produces": [
"application/json"
],
"tags": [
"repository"
],
"summary": "Gets the metadata and contents (if a file) of an entry in a repository, or a list of entries if a dir",
"summary": "Gets the metadata and contents (if a file) of an entry in a repository, or a list of entries if a dir.",