Skip to content

Commit 52fc7a2

Browse files
committed
adding reset branch api
1 parent 66840f8 commit 52fc7a2

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

lib/connectionConfig.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,14 @@ ConnectionConfig.prototype.branchURL = function(nuid) {
378378
return b + `/branch/${nuid}`
379379
}
380380

381+
/**
382+
* Generate URL for branch squash endpoint
383+
*/
384+
ConnectionConfig.prototype.squashBranchURL = function(nuid) {
385+
let b = this.repoBase('squash')
386+
return b + `/branch/${nuid}`
387+
}
388+
381389
/**
382390
* Generate base db url consisting of server/action/organization/dbid
383391
*/

lib/const.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ module.exports = Object.freeze({
3535
RESET: 'reset',
3636
BRANCH: 'branch',
3737
DELETE_BRANCH: 'delete_branch',
38+
RESET_BRANCH: 'reset_branch',
3839
ADD_CSV: 'add_csv',
3940
GET_CSV: 'get_csv',
4041
UPDATE_CSV: 'update_csv',

lib/woqlClient.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,21 @@ WOQLClient.prototype.branch = function(new_branch_id, source_free) {
570570
return Promise.reject(new Error(ErrorMessage.getInvalidParameterMessage(CONST.BRANCH, errmsg)))
571571
}
572572

573+
/**
574+
* Creates a branch starting from the current branch
575+
* @param {string} branch_id - local identifier of the new branch
576+
* @param {string} commit_msg - Textual message describing the reason for the update
577+
* @returns {Promise}
578+
*/
579+
WOQLClient.prototype.resetBranch = function(branch_id, commit_msg) {
580+
if (commit_msg && branch_id) {
581+
let commit = this.generateCommitInfo(commit_msg)
582+
return this.dispatch(CONST.RESET_BRANCH, this.connectionConfig.squashBranchURL(branch_id), commit)
583+
}
584+
let errmsg = `Branch parameter error - you must specify a valid new branch id and a commit message`
585+
return Promise.reject(new Error(ErrorMessage.getInvalidParameterMessage(CONST.BRANCH, errmsg)))
586+
}
587+
573588
/**
574589
* deletes a branch from database
575590
* @param {string} branch_id - local identifier of the branch

0 commit comments

Comments
 (0)