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
3fec2659
Commit
3fec2659
authored
Mar 24, 2021
by
Thomas Randolph
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch diffs to use the mrNotes store
... when getting the default suggestion commit message
parent
1c23b812
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
27 deletions
+46
-27
app/assets/javascripts/diffs/store/getters.js
app/assets/javascripts/diffs/store/getters.js
+6
-6
spec/frontend/diffs/store/getters_spec.js
spec/frontend/diffs/store/getters_spec.js
+28
-16
spec/frontend/notes/components/note_body_spec.js
spec/frontend/notes/components/note_body_spec.js
+12
-5
No files found.
app/assets/javascripts/diffs/store/getters.js
View file @
3fec2659
...
@@ -156,16 +156,16 @@ export const diffLines = (state) => (file, unifiedDiffComponents) => {
...
@@ -156,16 +156,16 @@ export const diffLines = (state) => (file, unifiedDiffComponents) => {
);
);
};
};
export
function
suggestionCommitMessage
(
state
)
{
export
function
suggestionCommitMessage
(
state
,
_
,
rootState
)
{
return
(
values
=
{})
=>
return
(
values
=
{})
=>
computeSuggestionCommitMessage
({
computeSuggestionCommitMessage
({
message
:
state
.
defaultSuggestionCommitMessage
,
message
:
state
.
defaultSuggestionCommitMessage
,
values
:
{
values
:
{
branch_name
:
state
.
branchN
ame
,
branch_name
:
rootState
.
page
.
mrMetadata
.
branch_n
ame
,
project_path
:
state
.
projectP
ath
,
project_path
:
rootState
.
page
.
mrMetadata
.
project_p
ath
,
project_name
:
state
.
projectN
ame
,
project_name
:
rootState
.
page
.
mrMetadata
.
project_n
ame
,
username
:
state
.
username
,
username
:
rootState
.
page
.
mrMetadata
.
username
,
user_full_name
:
state
.
userFullN
ame
,
user_full_name
:
rootState
.
page
.
mrMetadata
.
user_full_n
ame
,
...
values
,
...
values
,
},
},
});
});
...
...
spec/frontend/diffs/store/getters_spec.js
View file @
3fec2659
...
@@ -377,32 +377,40 @@ describe('Diffs Module Getters', () => {
...
@@ -377,32 +377,40 @@ describe('Diffs Module Getters', () => {
});
});
describe
(
'
suggestionCommitMessage
'
,
()
=>
{
describe
(
'
suggestionCommitMessage
'
,
()
=>
{
let
rootState
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
Object
.
assign
(
localState
,
{
Object
.
assign
(
localState
,
{
defaultSuggestionCommitMessage
:
defaultSuggestionCommitMessage
:
'
%{branch_name}%{project_path}%{project_name}%{username}%{user_full_name}%{file_paths}%{suggestions_count}%{files_count}
'
,
'
%{branch_name}%{project_path}%{project_name}%{username}%{user_full_name}%{file_paths}%{suggestions_count}%{files_count}
'
,
branchName
:
'
branch
'
,
projectPath
:
'
/path
'
,
projectName
:
'
name
'
,
username
:
'
user
'
,
userFullName
:
'
user userton
'
,
});
});
rootState
=
{
page
:
{
mrMetadata
:
{
branch_name
:
'
branch
'
,
project_path
:
'
/path
'
,
project_name
:
'
name
'
,
username
:
'
user
'
,
user_full_name
:
'
user userton
'
,
},
},
};
});
});
it
.
each
`
it
.
each
`
specialState | output
specialState | output
${{}}
|
$
{
'
branch/pathnameuseruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{}}
|
$
{
'
branch/pathnameuseruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
user
FullN
ame
:
null
}
} |
${
'
branch/pathnameuser%{user_full_name}%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
user
_full_n
ame
:
null
}
} |
${
'
branch/pathnameuser%{user_full_name}%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
username
:
null
}
} |
${
'
branch/pathname%{username}user userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
username
:
null
}
} |
${
'
branch/pathname%{username}user userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
project
Name
:
null
}
}
|
${
'
branch/path%{project_name}useruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
project
_name
:
null
}
}
|
${
'
branch/path%{project_name}useruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
project
Path
:
null
}
}
|
${
'
branch%{project_path}nameuseruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
project
_path
:
null
}
}
|
${
'
branch%{project_path}nameuseruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
branch
Name
:
null
}
}
|
${
'
%{branch_name}/pathnameuseruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
branch
_name
:
null
}
}
|
${
'
%{branch_name}/pathnameuseruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
`
(
`
(
'
provides the correct "base" default commit message based on state ($specialState)
'
,
'
provides the correct "base" default commit message based on state ($specialState)
'
,
({
specialState
,
output
})
=>
{
({
specialState
,
output
})
=>
{
Object
.
assign
(
localState
,
specialState
);
Object
.
assign
(
rootState
.
page
.
mrMetadata
,
specialState
);
expect
(
getters
.
suggestionCommitMessage
(
localState
)()).
toBe
(
output
);
expect
(
getters
.
suggestionCommitMessage
(
localState
,
null
,
rootState
)()).
toBe
(
output
);
},
},
);
);
...
@@ -417,7 +425,9 @@ describe('Diffs Module Getters', () => {
...
@@ -417,7 +425,9 @@ describe('Diffs Module Getters', () => {
`
(
`
(
"
properly overrides state values ($stateOverrides) if they're provided
"
,
"
properly overrides state values ($stateOverrides) if they're provided
"
,
({
stateOverrides
,
output
})
=>
{
({
stateOverrides
,
output
})
=>
{
expect
(
getters
.
suggestionCommitMessage
(
localState
)(
stateOverrides
)).
toBe
(
output
);
expect
(
getters
.
suggestionCommitMessage
(
localState
,
null
,
rootState
)(
stateOverrides
)).
toBe
(
output
,
);
},
},
);
);
...
@@ -431,7 +441,9 @@ describe('Diffs Module Getters', () => {
...
@@ -431,7 +441,9 @@ describe('Diffs Module Getters', () => {
`
(
`
(
"
fills in any missing interpolations ($providedValues) when they're provided at the getter callsite
"
,
"
fills in any missing interpolations ($providedValues) when they're provided at the getter callsite
"
,
({
providedValues
,
output
})
=>
{
({
providedValues
,
output
})
=>
{
expect
(
getters
.
suggestionCommitMessage
(
localState
)(
providedValues
)).
toBe
(
output
);
expect
(
getters
.
suggestionCommitMessage
(
localState
,
null
,
rootState
)(
providedValues
)).
toBe
(
output
,
);
},
},
);
);
});
});
...
...
spec/frontend/notes/components/note_body_spec.js
View file @
3fec2659
...
@@ -81,14 +81,21 @@ describe('issue_note_body component', () => {
...
@@ -81,14 +81,21 @@ describe('issue_note_body component', () => {
state
:
{
state
:
{
defaultSuggestionCommitMessage
:
defaultSuggestionCommitMessage
:
'
%{branch_name}%{project_path}%{project_name}%{username}%{user_full_name}%{file_paths}%{suggestions_count}%{files_count}
'
,
'
%{branch_name}%{project_path}%{project_name}%{username}%{user_full_name}%{file_paths}%{suggestions_count}%{files_count}
'
,
branchName
:
'
branch
'
,
projectPath
:
'
/path
'
,
projectName
:
'
name
'
,
username
:
'
user
'
,
userFullName
:
'
user userton
'
,
},
},
getters
:
{
suggestionCommitMessage
},
getters
:
{
suggestionCommitMessage
},
},
},
page
:
{
namespaced
:
true
,
state
:
{
mrMetadata
:
{
branch_name
:
'
branch
'
,
project_path
:
'
/path
'
,
project_name
:
'
name
'
,
username
:
'
user
'
,
user_full_name
:
'
user userton
'
,
},
},
},
},
},
});
});
...
...
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