summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/repo/services/repo_service.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/repo/services/repo_service.js')
-rw-r--r--app/assets/javascripts/repo/services/repo_service.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/assets/javascripts/repo/services/repo_service.js b/app/assets/javascripts/repo/services/repo_service.js
index d68d71a4629..786b5637493 100644
--- a/app/assets/javascripts/repo/services/repo_service.js
+++ b/app/assets/javascripts/repo/services/repo_service.js
@@ -1,8 +1,11 @@
import axios from 'axios';
+import csrf from '../../lib/utils/csrf';
import Store from '../stores/repo_store';
import Api from '../../api';
import Helper from '../helpers/repo_helper';
+axios.defaults.headers.common[csrf.headerKey] = csrf.token;
+
const RepoService = {
url: '',
options: {
@@ -10,6 +13,7 @@ const RepoService = {
format: 'json',
},
},
+ createBranchPath: '/api/:version/projects/:id/repository/branches',
richExtensionRegExp: /md/,
getRaw(url) {
@@ -73,6 +77,12 @@ const RepoService = {
.then(this.commitFlash);
},
+ createBranch(payload) {
+ const url = Api.buildUrl(this.createBranchPath)
+ .replace(':id', Store.projectId);
+ return axios.post(url, payload);
+ },
+
commitFlash(data) {
if (data.short_id && data.stats) {
window.Flash(`Your changes have been committed. Commit ${data.short_id} with ${data.stats.additions} additions, ${data.stats.deletions} deletions.`, 'notice');