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
ef4d3542
Commit
ef4d3542
authored
Apr 13, 2021
by
Samantha Ming
Committed by
Simon Knox
Apr 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix broken branch switch with similar names
parent
981959b8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
4 deletions
+18
-4
app/assets/javascripts/pages/projects/project.js
app/assets/javascripts/pages/projects/project.js
+13
-4
changelogs/unreleased/322792-switch-branch-of-shorter-name.yml
...elogs/unreleased/322792-switch-branch-of-shorter-name.yml
+5
-0
No files found.
app/assets/javascripts/pages/projects/project.js
View file @
ef4d3542
...
@@ -123,10 +123,19 @@ export default class Project {
...
@@ -123,10 +123,19 @@ export default class Project {
const
loc
=
window
.
location
.
href
;
const
loc
=
window
.
location
.
href
;
if
(
loc
.
includes
(
'
/-/
'
))
{
if
(
loc
.
includes
(
'
/-/
'
))
{
const
refs
=
this
.
fullData
.
Branches
.
concat
(
this
.
fullData
.
Tags
);
// Since the current ref in renderRow is outdated on page changes
const
currentRef
=
refs
.
find
((
ref
)
=>
loc
.
indexOf
(
ref
)
>
-
1
);
// (To be addressed in: https://gitlab.com/gitlab-org/gitlab/-/issues/327085)
if
(
currentRef
)
{
// We are deciphering the current ref from the dropdown data instead
const
targetPath
=
loc
.
split
(
currentRef
)[
1
].
slice
(
1
).
split
(
'
#
'
)[
0
];
const
currentRef
=
$dropdown
.
data
(
'
ref
'
);
// The split and startWith is to ensure an exact word match
// and avoid partial match ie. currentRef is "dev" and loc is "development"
const
splitPathAfterRefPortion
=
loc
.
split
(
currentRef
)[
1
];
const
doesPathContainRef
=
splitPathAfterRefPortion
?.
startsWith
(
'
/
'
);
if
(
doesPathContainRef
)
{
// We are ignoring the url containing the ref portion
// and plucking the thereafter portion to reconstructure the url that is correct
const
targetPath
=
splitPathAfterRefPortion
?.
slice
(
1
).
split
(
'
#
'
)[
0
];
selectedUrl
.
searchParams
.
set
(
'
path
'
,
targetPath
);
selectedUrl
.
searchParams
.
set
(
'
path
'
,
targetPath
);
selectedUrl
.
hash
=
window
.
location
.
hash
;
selectedUrl
.
hash
=
window
.
location
.
hash
;
}
}
...
...
changelogs/unreleased/322792-switch-branch-of-shorter-name.yml
0 → 100644
View file @
ef4d3542
---
title
:
Fix branch switch to be exact instead of partial match
merge_request
:
57197
author
:
type
:
fixed
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