summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-06-15 11:12:13 +0100
committerPhil Hughes <me@iamphill.com>2018-06-15 11:19:35 +0100
commit3530274b13ec4f20731f9f98ea94dabe1494072d (patch)
tree5400c31eaf71f4f9740a4666259ab987a508b547
parente906be2f683f6170a5ee1d5b5f104ab0e08062d1 (diff)
downloadgitlab-ce-ide-add-last-commit-id-to-api-call.tar.gz
only return last_commit_sha in the JSONide-add-last-commit-id-to-api-call
-rw-r--r--app/assets/javascripts/ide/stores/mutations/file.js2
-rw-r--r--app/assets/javascripts/ide/stores/utils.js3
-rw-r--r--app/controllers/projects/blob_controller.rb4
-rw-r--r--spec/javascripts/ide/stores/modules/commit/actions_spec.js4
-rw-r--r--spec/javascripts/ide/stores/utils_spec.js8
5 files changed, 8 insertions, 13 deletions
diff --git a/app/assets/javascripts/ide/stores/mutations/file.js b/app/assets/javascripts/ide/stores/mutations/file.js
index ef70679f20e..46547820425 100644
--- a/app/assets/javascripts/ide/stores/mutations/file.js
+++ b/app/assets/javascripts/ide/stores/mutations/file.js
@@ -47,7 +47,7 @@ export default {
baseRaw: null,
html: data.html,
size: data.size,
- lastCommit: data.last_commit,
+ lastCommitSha: data.last_commit_sha,
});
},
[types.SET_FILE_RAW_DATA](state, { file, raw }) {
diff --git a/app/assets/javascripts/ide/stores/utils.js b/app/assets/javascripts/ide/stores/utils.js
index 15305684aed..10368a4d97c 100644
--- a/app/assets/javascripts/ide/stores/utils.js
+++ b/app/assets/javascripts/ide/stores/utils.js
@@ -17,6 +17,7 @@ export const dataStructure = () => ({
changed: false,
staged: false,
lastCommitPath: '',
+ lastCommitSha: '',
lastCommit: {
id: '',
url: '',
@@ -112,7 +113,7 @@ export const createCommitPayload = ({ branch, newBranch, state, rootState }) =>
file_path: f.path,
content: f.content,
encoding: f.base64 ? 'base64' : 'text',
- last_commit_id: newBranch ? undefined : f.lastCommit.id,
+ last_commit_id: newBranch ? undefined : f.lastCommitSha,
})),
start_branch: newBranch ? rootState.currentBranchId : undefined,
});
diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb
index 1aee83f2f06..7c65f1f5dfe 100644
--- a/app/controllers/projects/blob_controller.rb
+++ b/app/controllers/projects/blob_controller.rb
@@ -197,13 +197,14 @@ class Projects::BlobController < Projects::ApplicationController
end
def show_json
+ set_last_commit_sha
path_segments = @path.split('/')
path_segments.pop
tree_path = path_segments.join('/')
- last_commit = @repository.last_commit_for_path(@commit.id, @blob.path)
json = {
id: @blob.id,
+ last_commit_sha: @last_commit_sha,
path: blob.path,
name: blob.name,
extension: blob.extension,
@@ -218,7 +219,6 @@ class Projects::BlobController < Projects::ApplicationController
blame_path: project_blame_path(project, @id),
commits_path: project_commits_path(project, @id),
tree_path: project_tree_path(project, File.join(@ref, tree_path)),
- last_commit: last_commit,
permalink: project_blob_path(project, File.join(@commit.id, @path))
}
diff --git a/spec/javascripts/ide/stores/modules/commit/actions_spec.js b/spec/javascripts/ide/stores/modules/commit/actions_spec.js
index 45101304a4c..133ad627f34 100644
--- a/spec/javascripts/ide/stores/modules/commit/actions_spec.js
+++ b/spec/javascripts/ide/stores/modules/commit/actions_spec.js
@@ -243,9 +243,7 @@ describe('IDE commit module actions', () => {
...file('changed'),
type: 'blob',
active: true,
- lastCommit: {
- id: '123456789',
- },
+ lastCommitSha: '123456789',
};
store.state.stagedFiles.push(f);
store.state.changedFiles = [
diff --git a/spec/javascripts/ide/stores/utils_spec.js b/spec/javascripts/ide/stores/utils_spec.js
index 3f06f287ba9..a7bd443af51 100644
--- a/spec/javascripts/ide/stores/utils_spec.js
+++ b/spec/javascripts/ide/stores/utils_spec.js
@@ -76,9 +76,7 @@ describe('Multi-file store utils', () => {
...file('staged'),
path: 'staged',
content: 'updated file content',
- lastCommit: {
- id: '123456789',
- },
+ lastCommitSha: '123456789',
},
{
...file('newFile'),
@@ -86,9 +84,7 @@ describe('Multi-file store utils', () => {
tempFile: true,
content: 'new file content',
base64: true,
- lastCommit: {
- id: '123456789',
- },
+ lastCommitSha: '123456789',
},
],
currentBranchId: 'master',