Skip to content

Commit 603a55f

Browse files
committed
adding delete branch api
1 parent 418b7d2 commit 603a55f

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

lib/const.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ module.exports = Object.freeze({
3434
REBASE: 'rebase',
3535
RESET: 'reset',
3636
BRANCH: 'branch',
37+
DELETE_BRANCH: 'delete_branch',
3738
ADD_CSV: 'add_csv',
3839
GET_CSV: 'get_csv',
3940
UPDATE_CSV: 'update_csv',

lib/dispatchRequest.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ function DispatchRequest(url, action, payload, local_auth, remote_auth = null) {
6666
case CONST.DELETE_CSV:
6767
case CONST.DELETE_GRAPH:
6868
case CONST.DELETE_USER:
69+
case CONST.DELETE_BRANCH:
6970
case CONST.DELETE_ORGANIZATION:
7071
if (payload) {
7172
options.headers = options.headers ? options.headers : {}

lib/woqlClient.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ WOQLClient.prototype.getCSV = function(csv_name, download, gtype, gid) {
492492
*/
493493
WOQLClient.prototype.message = function(message, endpoint) {
494494
const url = this.api()
495-
url += (endpoint ? this.api() + endpoint : "message")
495+
url += (endpoint ? this.api() + endpoint : "message")
496496
return this.dispatch(CONST.MESSAGE, url, message).then(response => {
497497
return response
498498
})
@@ -570,6 +570,19 @@ WOQLClient.prototype.branch = function(new_branch_id, source_free) {
570570
return Promise.reject(new Error(ErrorMessage.getInvalidParameterMessage(CONST.BRANCH, errmsg)))
571571
}
572572

573+
/**
574+
* deletes a branch from database
575+
* @param {string} branch_id - local identifier of the branch
576+
* @returns {Promise}
577+
*/
578+
WOQLClient.prototype.deleteBranch = function(branch_id) {
579+
if (branch_id) {
580+
return this.dispatch(CONST.DELETE_BRANCH, this.connectionConfig.branchURL(branch_id))
581+
}
582+
let errmsg = `Branch parameter error - you must specify a valid new branch id`
583+
return Promise.reject(new Error(ErrorMessage.getInvalidParameterMessage(CONST.BRANCH, errmsg)))
584+
}
585+
573586
/**
574587
* Pull updates from a remote repository to the current db and merges them
575588
* @param {object} [remote_source_repo] - source repo - {remote: "origin", "remote_branch": "main", "author": "admin", "message": "message"}

0 commit comments

Comments
 (0)