Add recursive parameter in Repository.getTree by aymen-mouelhi · Pull Request #443 · github-tools/github
Expand Up
@@ -235,11 +235,13 @@ class Repository extends Requestable {
* Get a description of a git tree
* @see https://developer.github.com/v3/git/trees/#get-a-tree
* @param {string} treeSHA - the SHA of the tree to fetch
* @param {boolean} recursive - Get tree recursively or not
* @param {Requestable.callback} cb - will receive the callback data
* @return {Promise} - the promise for the http request
*/
getTree(treeSHA, cb) {
return this._request('GET', `/repos/${this.__fullname}/git/trees/${treeSHA}`, null, cb);
getTree(treeSHA, recursive, cb) {
recursive = recursive ? '?recursive=true' : '';
return this._request('GET', `/repos/${this.__fullname}/git/trees/${treeSHA}${recursive}`, null, cb);
}
/** Expand Down Expand Up @@ -680,7 +682,7 @@ class Repository extends Requestable { move(branch, oldPath, newPath, cb) { let oldSha; return this.getRef(`heads/${branch}`) .then(({data: {object}}) => this.getTree(`${object.sha}?recursive=true`)) .then(({data: {object}}) => this.getTree(`${object.sha}`, true)) .then(({data: {tree, sha}}) => { oldSha = sha; let newTree = tree.map((ref) => { Expand Down
/** Expand Down Expand Up @@ -680,7 +682,7 @@ class Repository extends Requestable { move(branch, oldPath, newPath, cb) { let oldSha; return this.getRef(`heads/${branch}`) .then(({data: {object}}) => this.getTree(`${object.sha}?recursive=true`)) .then(({data: {object}}) => this.getTree(`${object.sha}`, true)) .then(({data: {tree, sha}}) => { oldSha = sha; let newTree = tree.map((ref) => { Expand Down