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
6154fb9e
Commit
6154fb9e
authored
Feb 01, 2021
by
Thomas Randolph
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add getter for the complete suggestion commit message
parent
bf4adbcd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
0 deletions
+76
-0
app/assets/javascripts/diffs/store/getters.js
app/assets/javascripts/diffs/store/getters.js
+16
-0
spec/frontend/diffs/store/getters_spec.js
spec/frontend/diffs/store/getters_spec.js
+60
-0
No files found.
app/assets/javascripts/diffs/store/getters.js
View file @
6154fb9e
...
...
@@ -4,6 +4,7 @@ import {
INLINE_DIFF_VIEW_TYPE
,
INLINE_DIFF_LINES_KEY
,
}
from
'
../constants
'
;
import
{
computeSuggestionCommitMessage
}
from
'
../utils/suggestions
'
;
import
{
parallelizeDiffLines
}
from
'
./utils
'
;
export
*
from
'
./getters_versions_dropdowns
'
;
...
...
@@ -154,3 +155,18 @@ export const diffLines = (state) => (file, unifiedDiffComponents) => {
state
.
diffViewType
===
INLINE_DIFF_VIEW_TYPE
,
);
};
export
function
suggestionCommitMessage
(
state
)
{
return
(
values
=
{})
=>
computeSuggestionCommitMessage
({
message
:
state
.
defaultSuggestionCommitMessage
,
values
:
{
branch_name
:
state
.
branchName
,
project_path
:
state
.
projectPath
,
project_name
:
state
.
projectName
,
username
:
state
.
username
,
user_full_name
:
state
.
userFullName
,
...
values
,
},
});
}
spec/frontend/diffs/store/getters_spec.js
View file @
6154fb9e
...
...
@@ -375,4 +375,64 @@ describe('Diffs Module Getters', () => {
});
});
});
describe
(
'
suggestionCommitMessage
'
,
()
=>
{
beforeEach
(()
=>
{
Object
.
assign
(
localState
,
{
defaultSuggestionCommitMessage
:
'
%{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
'
,
});
});
it
.
each
`
specialState | output
${{}}
|
$
{
'
branch/pathnameuseruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
userFullName
:
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}
'
}
${{
projectName
:
null
}
} |
${
'
branch/path%{project_name}useruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
projectPath
:
null
}
} |
${
'
branch%{project_path}nameuseruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
branchName
:
null
}
} |
${
'
%{branch_name}/pathnameuseruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
`
(
'
provides the correct "base" default commit message based on state ($specialState)
'
,
({
specialState
,
output
})
=>
{
Object
.
assign
(
localState
,
specialState
);
expect
(
getters
.
suggestionCommitMessage
(
localState
)()).
toBe
(
output
);
},
);
it
.
each
`
stateOverrides | output
${{}}
|
$
{
'
branch/pathnameuseruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
${{
user_full_name
:
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}
'
}
${{
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}
'
}
${{
branch_name
:
null
}
} |
${
'
%{branch_name}/pathnameuseruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
`
(
"
properly overrides state values ($stateOverrides) if they're provided
"
,
({
stateOverrides
,
output
})
=>
{
expect
(
getters
.
suggestionCommitMessage
(
localState
)(
stateOverrides
)).
toBe
(
output
);
},
);
it
.
each
`
providedValues | output
${{
file_paths
:
'
path1, path2
'
,
suggestions_count
:
1
,
files_count
:
1
}
} |
${
'
branch/pathnameuseruser usertonpath1, path211
'
}
${{
suggestions_count
:
1
,
files_count
:
1
}
} |
${
'
branch/pathnameuseruser userton%{file_paths}11
'
}
${{
file_paths
:
'
path1, path2
'
,
files_count
:
1
}
} |
${
'
branch/pathnameuseruser usertonpath1, path2%{suggestions_count}1
'
}
${{
file_paths
:
'
path1, path2
'
,
suggestions_count
:
1
}
} |
${
'
branch/pathnameuseruser usertonpath1, path21%{files_count}
'
}
${{
something_unused
:
'
CrAzY TeXt
'
}
} |
${
'
branch/pathnameuseruser userton%{file_paths}%{suggestions_count}%{files_count}
'
}
`
(
"
fills in any missing interpolations ($providedValues) when they're provided at the getter callsite
"
,
({
providedValues
,
output
})
=>
{
expect
(
getters
.
suggestionCommitMessage
(
localState
)(
providedValues
)).
toBe
(
output
);
},
);
});
});
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