Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Schatz <jschatz1@gmail.com>2017-09-29 18:31:51 +0300
committerJacob Schatz <jschatz1@gmail.com>2017-10-02 19:31:20 +0300
commit419954173445e9af0f0a3954baf303d84674160a (patch)
treedae3a5bdd27684b3862de5b0b202e555f1d4ec99
parentf1b8d79f4ac0cc9f145f690ad7df095798a7ac5d (diff)
Check for branch changes.
-rw-r--r--app/assets/javascripts/api.js13
-rw-r--r--app/assets/javascripts/repo/components/repo_commit_section.vue8
-rw-r--r--app/assets/javascripts/repo/index.js2
-rw-r--r--app/assets/javascripts/repo/services/repo_service.js4
-rw-r--r--app/assets/javascripts/repo/stores/repo_store.js16
5 files changed, 42 insertions, 1 deletions
diff --git a/app/assets/javascripts/api.js b/app/assets/javascripts/api.js
index 38d1effc77c..1719b2b57a5 100644
--- a/app/assets/javascripts/api.js
+++ b/app/assets/javascripts/api.js
@@ -15,6 +15,7 @@ const Api = {
issuableTemplatePath: '/:namespace_path/:project_path/templates/:type/:key',
usersPath: '/api/:version/users.json',
commitPath: '/api/:version/projects/:id/repository/commits',
+ branchSinglePath: '/api/:version/projects/:id/repository/branches/:branch',
group(groupId, callback) {
const url = Api.buildUrl(Api.groupPath)
@@ -123,6 +124,18 @@ const Api = {
});
},
+ branchSingle(id, branch) {
+ const url = Api.buildUrl(Api.branchSinglePath)
+ .replace(':id', id)
+ .replace(':branch', branch);
+ return this.wrapAjaxCall({
+ url,
+ type: 'GET',
+ contentType: "application/json; charset=utf-8",
+ dataType: 'json',
+ });
+ },
+
// Return text for a specific license
licenseText(key, data, callback) {
const url = Api.buildUrl(Api.licensePath)
diff --git a/app/assets/javascripts/repo/components/repo_commit_section.vue b/app/assets/javascripts/repo/components/repo_commit_section.vue
index 119e38c583d..86b9c6c91d0 100644
--- a/app/assets/javascripts/repo/components/repo_commit_section.vue
+++ b/app/assets/javascripts/repo/components/repo_commit_section.vue
@@ -19,7 +19,7 @@ export default {
},
cantCommitYet() {
- return !this.commitMessage || this.submitCommitsLoading;
+ return !this.commitMessage || this.submitCommitsLoading || this.branchChanged;
},
filePluralize() {
@@ -29,6 +29,12 @@ export default {
methods: {
makeCommit() {
+ Store.setBranchHash()
+ .then(() => {
+ if(Store.branchChanged){
+ console.log('branch has changed')
+ }
+ })
// see https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions
const commitMessage = this.commitMessage;
const actions = this.changedFiles.map(f => ({
diff --git a/app/assets/javascripts/repo/index.js b/app/assets/javascripts/repo/index.js
index 7d0123e3d3a..aa19fea6f02 100644
--- a/app/assets/javascripts/repo/index.js
+++ b/app/assets/javascripts/repo/index.js
@@ -32,7 +32,9 @@ function setInitialStore(data) {
Store.canCommit = data.canCommit;
Store.onTopOfBranch = data.onTopOfBranch;
Store.currentBranch = $('button.dropdown-menu-toggle').attr('data-ref');
+
Store.checkIsCommitable();
+ Store.setBranchHash();
}
function initRepo(el) {
diff --git a/app/assets/javascripts/repo/services/repo_service.js b/app/assets/javascripts/repo/services/repo_service.js
index af83497fa39..bf2309a4d78 100644
--- a/app/assets/javascripts/repo/services/repo_service.js
+++ b/app/assets/javascripts/repo/services/repo_service.js
@@ -65,6 +65,10 @@ const RepoService = {
return urlArray.join('/');
},
+ branchSingle() {
+ return Api.branchSingle(Store.projectId, Store.currentBranch);
+ },
+
commitFiles(payload) {
return Api.commitMultiple(Store.projectId, payload)
.then(this.commitFlash);
diff --git a/app/assets/javascripts/repo/stores/repo_store.js b/app/assets/javascripts/repo/stores/repo_store.js
index 9a4fc40bc69..2155ce2f809 100644
--- a/app/assets/javascripts/repo/stores/repo_store.js
+++ b/app/assets/javascripts/repo/stores/repo_store.js
@@ -32,6 +32,8 @@ const RepoStore = {
isCommitable: false,
binary: false,
currentBranch: '',
+ initialHash: '',
+ branchChanged: false,
commitMessage: '',
binaryTypes: {
png: false,
@@ -50,6 +52,20 @@ const RepoStore = {
});
},
+ setBranchHash() {
+ return Service.branchSingle()
+ .then((data) => {
+ if(RepoStore.initialHash !== '' && data.commit.id !== RepoStore.initialHash) {
+ RepoStore.branchChanged = true;
+ }
+ RepoStore.initialHash = data.commit.id;
+ });
+ },
+
+ hasBranchChanged() {
+
+ },
+
// mutations
checkIsCommitable() {
RepoStore.isCommitable = RepoStore.onTopOfBranch && RepoStore.canCommit;