summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/repo/stores/actions/branch.js
blob: b81a70dfd1e4656bfb3447862fb791eae09e0ab3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import service from '../../services';
import * as types from '../mutation_types';
import { pushState } from '../utils';

// eslint-disable-next-line import/prefer-default-export
export const createNewBranch = ({ rootState, commit }, branch) => service.createBranch(
  rootState.project.id,
  {
    branch,
    ref: rootState.currentBranch,
  },
).then(res => res.json())
.then((data) => {
  const branchName = data.name;
  const url = location.href.replace(rootState.currentBranch, branchName);

  pushState(url);

  commit(types.SET_CURRENT_BRANCH, branchName);
});