-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@runlightyear/github": minor | ||
--- | ||
|
||
getTree method added |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
packages/@runlightyear/github/src/gitDatabase/trees/getTree.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { HttpProxyResponse } from "@runlightyear/lightyear"; | ||
import { Tree } from "../../types/Tree"; | ||
import { GitHub } from "../../GitHub"; | ||
|
||
/** | ||
* Path parameters | ||
* Name, Type, Description | ||
* owner string Required | ||
* The account owner of the repository. The name is not case sensitive. | ||
* | ||
* repo string Required | ||
* The name of the repository without the .git extension. The name is not case sensitive. | ||
* | ||
* tree_sha string Required | ||
* The SHA1 value or ref (branch or tag) name of the tree. | ||
* | ||
* Query parameters | ||
* Name, Type, Description | ||
* recursive string | ||
* Setting this parameter to any value returns the objects or subtrees referenced by the tree specified in :tree_sha. For example, setting recursive to any of the following will enable returning objects or subtrees: 0, 1, "true", and "false". Omit this parameter to prevent recursively returning objects or subtrees. | ||
*/ | ||
export interface GetTreeProps { | ||
/** | ||
* The account owner of the repository. The name is not case sensitive. | ||
*/ | ||
owner: string; | ||
/** | ||
* The name of the repository without the .git extension. The name is not case sensitive. | ||
*/ | ||
repo: string; | ||
/** | ||
* The SHA1 value or ref (branch or tag) name of the tree. | ||
*/ | ||
treeSha: string; | ||
/** | ||
* Setting this parameter to any value returns the objects or subtrees referenced by the tree specified in :tree_sha. For example, setting recursive to any of the following will enable returning objects or subtrees: 0, 1, "true", and "false". Omit this parameter to prevent recursively returning objects or subtrees. | ||
*/ | ||
recursive?: string | boolean | number; | ||
} | ||
|
||
export interface TreeResponse extends HttpProxyResponse { | ||
data: Tree; | ||
} | ||
|
||
export const getTree = | ||
(self: GitHub) => | ||
async (props: GetTreeProps): Promise<TreeResponse> => { | ||
const { owner, repo, treeSha, recursive } = props; | ||
|
||
return await self.get({ | ||
url: `/repos/${owner}/${repo}/git/trees/${treeSha}`, | ||
params: { recursive }, | ||
}); | ||
}; |