Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
32f39fb2
Commit
32f39fb2
authored
Jun 15, 2018
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-06-15
parents
883f083a
2634ef3d
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
184 additions
and
147 deletions
+184
-147
app/assets/javascripts/ide/services/index.js
app/assets/javascripts/ide/services/index.js
+1
-1
app/assets/javascripts/ide/stores/modules/commit/actions.js
app/assets/javascripts/ide/stores/modules/commit/actions.js
+17
-45
app/assets/javascripts/ide/stores/mutations/file.js
app/assets/javascripts/ide/stores/mutations/file.js
+1
-0
app/assets/javascripts/ide/stores/utils.js
app/assets/javascripts/ide/stores/utils.js
+3
-1
app/assets/javascripts/merge_conflicts/merge_conflicts_bundle.js
...ets/javascripts/merge_conflicts/merge_conflicts_bundle.js
+20
-15
app/controllers/concerns/internal_redirect.rb
app/controllers/concerns/internal_redirect.rb
+4
-0
app/controllers/projects/blob_controller.rb
app/controllers/projects/blob_controller.rb
+8
-5
spec/controllers/concerns/internal_redirect_spec.rb
spec/controllers/concerns/internal_redirect_spec.rb
+25
-0
spec/controllers/projects/blob_controller_spec.rb
spec/controllers/projects/blob_controller_spec.rb
+19
-0
spec/features/projects/deploy_keys_spec.rb
spec/features/projects/deploy_keys_spec.rb
+2
-1
spec/javascripts/ide/stores/modules/commit/actions_spec.js
spec/javascripts/ide/stores/modules/commit/actions_spec.js
+28
-71
spec/javascripts/ide/stores/utils_spec.js
spec/javascripts/ide/stores/utils_spec.js
+56
-0
spec/models/ci/build_trace_chunk_spec.rb
spec/models/ci/build_trace_chunk_spec.rb
+0
-8
No files found.
app/assets/javascripts/ide/services/index.js
View file @
32f39fb2
...
...
@@ -9,7 +9,7 @@ export default {
return
Vue
.
http
.
get
(
endpoint
,
{
params
:
{
format
:
'
json
'
}
});
},
getFileData
(
endpoint
)
{
return
Vue
.
http
.
get
(
endpoint
,
{
params
:
{
format
:
'
json
'
}
});
return
Vue
.
http
.
get
(
endpoint
,
{
params
:
{
format
:
'
json
'
,
viewer
:
'
none
'
}
});
},
getRawFileData
(
file
)
{
if
(
file
.
tempFile
)
{
...
...
app/assets/javascripts/ide/stores/modules/commit/actions.js
View file @
32f39fb2
...
...
@@ -49,31 +49,6 @@ export const setLastCommitMessage = ({ rootState, commit }, data) => {
commit
(
rootTypes
.
SET_LAST_COMMIT_MSG
,
commitMsg
,
{
root
:
true
});
};
export
const
checkCommitStatus
=
({
rootState
})
=>
service
.
getBranchData
(
rootState
.
currentProjectId
,
rootState
.
currentBranchId
)
.
then
(({
data
})
=>
{
const
{
id
}
=
data
.
commit
;
const
selectedBranch
=
rootState
.
projects
[
rootState
.
currentProjectId
].
branches
[
rootState
.
currentBranchId
];
if
(
selectedBranch
.
workingReference
!==
id
)
{
return
true
;
}
return
false
;
})
.
catch
(()
=>
flash
(
__
(
'
Error checking branch data. Please try again.
'
),
'
alert
'
,
document
,
null
,
false
,
true
,
),
);
export
const
updateFilesAfterCommit
=
({
commit
,
dispatch
,
rootState
},
{
data
})
=>
{
const
selectedProject
=
rootState
.
projects
[
rootState
.
currentProjectId
];
const
lastCommit
=
{
...
...
@@ -128,24 +103,17 @@ export const updateFilesAfterCommit = ({ commit, dispatch, rootState }, { data }
export
const
commitChanges
=
({
commit
,
state
,
getters
,
dispatch
,
rootState
,
rootGetters
})
=>
{
const
newBranch
=
state
.
commitAction
!==
consts
.
COMMIT_TO_CURRENT_BRANCH
;
const
payload
=
createCommitPayload
(
getters
.
branchName
,
newBranch
,
state
,
rootState
);
const
getCommitStatus
=
newBranch
?
Promise
.
resolve
(
false
)
:
dispatch
(
'
checkCommitStatus
'
);
const
payload
=
createCommitPayload
({
branch
:
getters
.
branchName
,
newBranch
,
state
,
rootState
,
});
commit
(
types
.
UPDATE_LOADING
,
true
);
return
getCommitStatus
.
then
(
branchChanged
=>
new
Promise
(
resolve
=>
{
if
(
branchChanged
)
{
// show the modal with a Bootstrap call
$
(
'
#ide-create-branch-modal
'
).
modal
(
'
show
'
);
}
else
{
resolve
();
}
}),
)
.
then
(()
=>
service
.
commit
(
rootState
.
currentProjectId
,
payload
))
return
service
.
commit
(
rootState
.
currentProjectId
,
payload
)
.
then
(({
data
})
=>
{
commit
(
types
.
UPDATE_LOADING
,
false
);
...
...
@@ -220,12 +188,16 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo
);
})
.
catch
(
err
=>
{
let
errMsg
=
__
(
'
Error committing changes. Please try again.
'
);
if
(
err
.
response
.
data
&&
err
.
response
.
data
.
message
)
{
errMsg
+=
` (
${
stripHtml
(
err
.
response
.
data
.
message
)}
)`
;
if
(
err
.
response
.
status
===
400
)
{
$
(
'
#ide-create-branch-modal
'
).
modal
(
'
show
'
);
}
else
{
let
errMsg
=
__
(
'
Error committing changes. Please try again.
'
);
if
(
err
.
response
.
data
&&
err
.
response
.
data
.
message
)
{
errMsg
+=
` (
${
stripHtml
(
err
.
response
.
data
.
message
)}
)`
;
}
flash
(
errMsg
,
'
alert
'
,
document
,
null
,
false
,
true
);
window
.
dispatchEvent
(
new
Event
(
'
resize
'
));
}
flash
(
errMsg
,
'
alert
'
,
document
,
null
,
false
,
true
);
window
.
dispatchEvent
(
new
Event
(
'
resize
'
));
commit
(
types
.
UPDATE_LOADING
,
false
);
});
...
...
app/assets/javascripts/ide/stores/mutations/file.js
View file @
32f39fb2
...
...
@@ -47,6 +47,7 @@ export default {
baseRaw
:
null
,
html
:
data
.
html
,
size
:
data
.
size
,
lastCommitSha
:
data
.
last_commit_sha
,
});
},
[
types
.
SET_FILE_RAW_DATA
](
state
,
{
file
,
raw
})
{
...
...
app/assets/javascripts/ide/stores/utils.js
View file @
32f39fb2
...
...
@@ -17,6 +17,7 @@ export const dataStructure = () => ({
changed
:
false
,
staged
:
false
,
lastCommitPath
:
''
,
lastCommitSha
:
''
,
lastCommit
:
{
id
:
''
,
url
:
''
,
...
...
@@ -104,7 +105,7 @@ export const setPageTitle = title => {
document
.
title
=
title
;
};
export
const
createCommitPayload
=
(
branch
,
newBranch
,
state
,
rootState
)
=>
({
export
const
createCommitPayload
=
(
{
branch
,
newBranch
,
state
,
rootState
}
)
=>
({
branch
,
commit_message
:
state
.
commitMessage
,
actions
:
rootState
.
stagedFiles
.
map
(
f
=>
({
...
...
@@ -112,6 +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
.
lastCommitSha
,
})),
start_branch
:
newBranch
?
rootState
.
currentBranchId
:
undefined
,
});
...
...
app/assets/javascripts/merge_conflicts/merge_conflicts_bundle.js
View file @
32f39fb2
/* eslint-disable new-cap, comma-dangle, no-new */
import
$
from
'
jquery
'
;
import
Vue
from
'
vue
'
;
import
Flash
from
'
../flash
'
;
import
create
Flash
from
'
../flash
'
;
import
initIssuableSidebar
from
'
../init_issuable_sidebar
'
;
import
'
./merge_conflict_store
'
;
import
MergeConflictsService
from
'
./merge_conflict_service
'
;
import
'
./mixins/line_conflict_utils
'
;
import
'
./mixins/line_conflict_actions
'
;
import
'
./components/diff_file_editor
'
;
import
'
./components/inline_conflict_lines
'
;
import
'
./components/parallel_conflict_lines
'
;
...
...
@@ -19,7 +15,7 @@ export default function initMergeConflicts() {
const
mergeConflictsStore
=
gl
.
mergeConflicts
.
mergeConflictsStore
;
const
mergeConflictsService
=
new
MergeConflictsService
({
conflictsPath
:
conflictsEl
.
dataset
.
conflictsPath
,
resolveConflictsPath
:
conflictsEl
.
dataset
.
resolveConflictsPath
resolveConflictsPath
:
conflictsEl
.
dataset
.
resolveConflictsPath
,
});
initIssuableSidebar
();
...
...
@@ -29,17 +25,26 @@ export default function initMergeConflicts() {
components
:
{
'
diff-file-editor
'
:
gl
.
mergeConflicts
.
diffFileEditor
,
'
inline-conflict-lines
'
:
gl
.
mergeConflicts
.
inlineConflictLines
,
'
parallel-conflict-lines
'
:
gl
.
mergeConflicts
.
parallelConflictLines
'
parallel-conflict-lines
'
:
gl
.
mergeConflicts
.
parallelConflictLines
,
},
data
:
mergeConflictsStore
.
state
,
computed
:
{
conflictsCountText
()
{
return
mergeConflictsStore
.
getConflictsCountText
();
},
readyToCommit
()
{
return
mergeConflictsStore
.
isReadyToCommit
();
},
commitButtonText
()
{
return
mergeConflictsStore
.
getCommitButtonText
();
},
showDiffViewTypeSwitcher
()
{
return
mergeConflictsStore
.
fileTextTypePresent
();
}
conflictsCountText
()
{
return
mergeConflictsStore
.
getConflictsCountText
();
},
readyToCommit
()
{
return
mergeConflictsStore
.
isReadyToCommit
();
},
commitButtonText
()
{
return
mergeConflictsStore
.
getCommitButtonText
();
},
showDiffViewTypeSwitcher
()
{
return
mergeConflictsStore
.
fileTextTypePresent
();
},
},
created
()
{
mergeConflictsService
.
fetchConflictsData
()
mergeConflictsService
.
fetchConflictsData
()
.
then
(({
data
})
=>
{
if
(
data
.
type
===
'
error
'
)
{
mergeConflictsStore
.
setFailedRequest
(
data
.
message
);
...
...
@@ -87,9 +92,9 @@ export default function initMergeConflicts() {
})
.
catch
(()
=>
{
mergeConflictsStore
.
setSubmitState
(
false
);
new
Flash
(
'
Failed to save merge conflicts resolutions. Please try again!
'
);
create
Flash
(
'
Failed to save merge conflicts resolutions. Please try again!
'
);
});
}
}
}
,
}
,
});
}
app/controllers/concerns/internal_redirect.rb
View file @
32f39fb2
...
...
@@ -24,6 +24,10 @@ module InternalRedirect
nil
end
def
sanitize_redirect
(
url_or_path
)
safe_redirect_path
(
url_or_path
)
||
safe_redirect_path_for_url
(
url_or_path
)
end
def
host_allowed?
(
uri
)
uri
.
host
==
request
.
host
&&
uri
.
port
==
request
.
port
...
...
app/controllers/projects/blob_controller.rb
View file @
32f39fb2
...
...
@@ -197,15 +197,14 @@ class Projects::BlobController < Projects::ApplicationController
end
def
show_json
json
=
blob_json
(
@blob
)
return
render_404
unless
json
set_last_commit_sha
path_segments
=
@path
.
split
(
'/'
)
path_segments
.
pop
tree_path
=
path_segments
.
join
(
'/'
)
render
json:
json
.
merge
(
json
=
{
id:
@blob
.
id
,
last_commit_sha:
@last_commit_sha
,
path:
blob
.
path
,
name:
blob
.
name
,
extension:
blob
.
extension
,
...
...
@@ -221,6 +220,10 @@ class Projects::BlobController < Projects::ApplicationController
commits_path:
project_commits_path
(
project
,
@id
),
tree_path:
project_tree_path
(
project
,
File
.
join
(
@ref
,
tree_path
)),
permalink:
project_blob_path
(
project
,
File
.
join
(
@commit
.
id
,
@path
))
)
}
json
.
merge!
(
blob_json
(
@blob
)
||
{})
unless
params
[
:viewer
]
==
'none'
render
json:
json
end
end
spec/controllers/concerns/internal_redirect_spec.rb
View file @
32f39fb2
...
...
@@ -54,6 +54,31 @@ describe InternalRedirect do
end
end
describe
'#sanitize_redirect'
do
let
(
:valid_path
)
{
'/hello/world?hello=world'
}
let
(
:valid_url
)
{
"http://test.host
#{
valid_path
}
"
}
it
'returns `nil` for invalid paths'
do
invalid_path
=
'//not/valid'
expect
(
controller
.
sanitize_redirect
(
invalid_path
)).
to
eq
nil
end
it
'returns `nil` for invalid urls'
do
input
=
'http://test.host:3000/invalid'
expect
(
controller
.
sanitize_redirect
(
input
)).
to
eq
nil
end
it
'returns input for valid paths'
do
expect
(
controller
.
sanitize_redirect
(
valid_path
)).
to
eq
valid_path
end
it
'returns path for valid urls'
do
expect
(
controller
.
sanitize_redirect
(
valid_url
)).
to
eq
valid_path
end
end
describe
'#host_allowed?'
do
it
'allows uris with the same host and port'
do
expect
(
controller
.
host_allowed?
(
URI
(
'http://test.host/test'
))).
to
be
(
true
)
...
...
spec/controllers/projects/blob_controller_spec.rb
View file @
32f39fb2
...
...
@@ -55,6 +55,25 @@ describe Projects::BlobController do
expect
(
json_response
).
to
have_key
'raw_path'
end
end
context
"with viewer=none"
do
let
(
:id
)
{
'master/README.md'
}
before
do
get
(
:show
,
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
id
,
format: :json
,
viewer:
'none'
)
end
it
do
expect
(
response
).
to
be_ok
expect
(
json_response
).
not_to
have_key
'html'
expect
(
json_response
).
to
have_key
'raw_path'
end
end
end
context
'with tree path'
do
...
...
spec/features/projects/deploy_keys_spec.rb
View file @
32f39fb2
...
...
@@ -22,7 +22,8 @@ describe 'Project deploy keys', :js do
accept_confirm
{
find
(
'.ic-remove'
).
click
()
}
expect
(
page
).
not_to
have_selector
(
'.fa-spinner'
,
count:
0
)
wait_for_requests
expect
(
page
).
to
have_selector
(
'.deploy-key'
,
count:
0
)
end
end
...
...
spec/javascripts/ide/stores/modules/commit/actions_spec.js
View file @
32f39fb2
...
...
@@ -108,77 +108,6 @@ describe('IDE commit module actions', () => {
});
});
describe
(
'
checkCommitStatus
'
,
()
=>
{
beforeEach
(()
=>
{
store
.
state
.
currentProjectId
=
'
abcproject
'
;
store
.
state
.
currentBranchId
=
'
master
'
;
store
.
state
.
projects
.
abcproject
=
{
branches
:
{
master
:
{
workingReference
:
'
1
'
,
},
},
};
});
it
(
'
calls service
'
,
done
=>
{
spyOn
(
service
,
'
getBranchData
'
).
and
.
returnValue
(
Promise
.
resolve
({
data
:
{
commit
:
{
id
:
'
123
'
},
},
}),
);
store
.
dispatch
(
'
commit/checkCommitStatus
'
)
.
then
(()
=>
{
expect
(
service
.
getBranchData
).
toHaveBeenCalledWith
(
'
abcproject
'
,
'
master
'
);
done
();
})
.
catch
(
done
.
fail
);
});
it
(
'
returns true if current ref does not equal returned ID
'
,
done
=>
{
spyOn
(
service
,
'
getBranchData
'
).
and
.
returnValue
(
Promise
.
resolve
({
data
:
{
commit
:
{
id
:
'
123
'
},
},
}),
);
store
.
dispatch
(
'
commit/checkCommitStatus
'
)
.
then
(
val
=>
{
expect
(
val
).
toBeTruthy
();
done
();
})
.
catch
(
done
.
fail
);
});
it
(
'
returns false if current ref equals returned ID
'
,
done
=>
{
spyOn
(
service
,
'
getBranchData
'
).
and
.
returnValue
(
Promise
.
resolve
({
data
:
{
commit
:
{
id
:
'
1
'
},
},
}),
);
store
.
dispatch
(
'
commit/checkCommitStatus
'
)
.
then
(
val
=>
{
expect
(
val
).
toBeFalsy
();
done
();
})
.
catch
(
done
.
fail
);
});
});
describe
(
'
updateFilesAfterCommit
'
,
()
=>
{
const
data
=
{
id
:
'
123
'
,
...
...
@@ -314,6 +243,7 @@ describe('IDE commit module actions', () => {
...
file
(
'
changed
'
),
type
:
'
blob
'
,
active
:
true
,
lastCommitSha
:
'
123456789
'
,
};
store
.
state
.
stagedFiles
.
push
(
f
);
store
.
state
.
changedFiles
=
[
...
...
@@ -366,6 +296,7 @@ describe('IDE commit module actions', () => {
file_path
:
jasmine
.
anything
(),
content
:
jasmine
.
anything
(),
encoding
:
jasmine
.
anything
(),
last_commit_id
:
undefined
,
},
],
start_branch
:
'
master
'
,
...
...
@@ -376,6 +307,32 @@ describe('IDE commit module actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
sends lastCommit ID when not creating new branch
'
,
done
=>
{
store
.
state
.
commit
.
commitAction
=
'
1
'
;
store
.
dispatch
(
'
commit/commitChanges
'
)
.
then
(()
=>
{
expect
(
service
.
commit
).
toHaveBeenCalledWith
(
'
abcproject
'
,
{
branch
:
jasmine
.
anything
(),
commit_message
:
'
testing 123
'
,
actions
:
[
{
action
:
'
update
'
,
file_path
:
jasmine
.
anything
(),
content
:
jasmine
.
anything
(),
encoding
:
jasmine
.
anything
(),
last_commit_id
:
'
123456789
'
,
},
],
start_branch
:
undefined
,
});
done
();
})
.
catch
(
done
.
fail
);
});
it
(
'
sets last Commit Msg
'
,
done
=>
{
store
.
dispatch
(
'
commit/commitChanges
'
)
...
...
spec/javascripts/ide/stores/utils_spec.js
View file @
32f39fb2
import
*
as
utils
from
'
~/ide/stores/utils
'
;
import
{
file
}
from
'
../helpers
'
;
describe
(
'
Multi-file store utils
'
,
()
=>
{
describe
(
'
setPageTitle
'
,
()
=>
{
...
...
@@ -63,4 +64,59 @@ describe('Multi-file store utils', () => {
expect
(
foundEntry
).
toBeUndefined
();
});
});
describe
(
'
createCommitPayload
'
,
()
=>
{
it
(
'
returns API payload
'
,
()
=>
{
const
state
=
{
commitMessage
:
'
commit message
'
,
};
const
rootState
=
{
stagedFiles
:
[
{
...
file
(
'
staged
'
),
path
:
'
staged
'
,
content
:
'
updated file content
'
,
lastCommitSha
:
'
123456789
'
,
},
{
...
file
(
'
newFile
'
),
path
:
'
added
'
,
tempFile
:
true
,
content
:
'
new file content
'
,
base64
:
true
,
lastCommitSha
:
'
123456789
'
,
},
],
currentBranchId
:
'
master
'
,
};
const
payload
=
utils
.
createCommitPayload
({
branch
:
'
master
'
,
newBranch
:
false
,
state
,
rootState
,
});
expect
(
payload
).
toEqual
({
branch
:
'
master
'
,
commit_message
:
'
commit message
'
,
actions
:
[
{
action
:
'
update
'
,
file_path
:
'
staged
'
,
content
:
'
updated file content
'
,
encoding
:
'
text
'
,
last_commit_id
:
'
123456789
'
,
},
{
action
:
'
create
'
,
file_path
:
'
added
'
,
content
:
'
new file content
'
,
encoding
:
'
base64
'
,
last_commit_id
:
'
123456789
'
,
},
],
start_branch
:
undefined
,
});
});
});
});
spec/models/ci/build_trace_chunk_spec.rb
View file @
32f39fb2
...
...
@@ -54,14 +54,6 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
it
{
is_expected
.
to
eq
(
'Sample data in db'
)
}
end
context
'when data_store is others'
do
before
do
build_trace_chunk
.
send
(
:write_attribute
,
:data_store
,
-
1
)
end
it
{
expect
{
subject
}.
to
raise_error
(
'Unsupported data store'
)
}
end
end
describe
'#set_data'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment