Skip to content

Commit

Permalink
Merge pull request #62 from M0nkeySan/fix/search-mr
Browse files Browse the repository at this point in the history
fix(search-mr): Fix the searchMergeRequestByUrl function to handle /-/ in the URL
  • Loading branch information
greg0ire authored Oct 31, 2024
2 parents f470aaa + 2571bf8 commit 14e74f4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion __tests__/__fixtures__/mergeRequestDetailsFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const mergeRequestDetailsFixture: GitlabMergeRequestDetails = {
force_remove_source_branch: false,
allow_collaboration: false,
allow_maintainer_to_push: false,
web_url: 'http://gitlab.example.com/my-group/my-project/merge_requests/1',
web_url: 'http://gitlab.example.com/my-group/my-project/-/merge_requests/1',
references: {
short: '!1',
relative: '!1',
Expand Down
2 changes: 1 addition & 1 deletion __tests__/__fixtures__/mergeRequestFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const mergeRequestFixture: GitlabMergeRequest = {
force_remove_source_branch: false,
allow_collaboration: false,
allow_maintainer_to_push: false,
web_url: 'http://gitlab.example.com/my-group/my-project/merge_requests/1',
web_url: 'http://gitlab.example.com/my-group/my-project/-/merge_requests/1',
references: {
short: '!1',
relative: 'my-group/my-project!1',
Expand Down
12 changes: 6 additions & 6 deletions __tests__/release/createRelease.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ describe('release > createRelease', () => {
{
block_id: 'release-changelog-block',
text: {
text: '• <http://gitlab.example.com/my-group/my-project/merge_requests/1|feat(great): implement great feature> - <https://my-ticket-management.com/view/SPAR-156|SPAR-156>\n• <http://gitlab.example.com/my-group/my-project/merge_requests/1|feat(great): implement another great feature> - <https://my-ticket-management.com/view/SPAR-158|SPAR-158>\n',
text: '• <http://gitlab.example.com/my-group/my-project/-/merge_requests/1|feat(great): implement great feature> - <https://my-ticket-management.com/view/SPAR-156|SPAR-156>\n• <http://gitlab.example.com/my-group/my-project/-/merge_requests/1|feat(great): implement another great feature> - <https://my-ticket-management.com/view/SPAR-158|SPAR-158>\n',
type: 'mrkdwn',
},
type: 'section',
Expand Down Expand Up @@ -406,7 +406,7 @@ describe('release > createRelease', () => {
{
block_id: 'release-changelog-block',
text: {
text: '• <http://gitlab.example.com/my-group/my-project/merge_requests/1|feat(great): implement great feature> - <https://my-ticket-management.com/view/SPAR-156|SPAR-156>\n• <http://gitlab.example.com/my-group/my-project/merge_requests/1|feat(great): implement another great feature> - <https://my-ticket-management.com/view/SPAR-158|SPAR-158>\n',
text: '• <http://gitlab.example.com/my-group/my-project/-/merge_requests/1|feat(great): implement great feature> - <https://my-ticket-management.com/view/SPAR-156|SPAR-156>\n• <http://gitlab.example.com/my-group/my-project/-/merge_requests/1|feat(great): implement another great feature> - <https://my-ticket-management.com/view/SPAR-158|SPAR-158>\n',
type: 'mrkdwn',
},
type: 'section',
Expand Down Expand Up @@ -567,7 +567,7 @@ describe('release > createRelease', () => {
).toEqual(true);
expect(releaseCallMock.called).toEqual(true);
expect(releaseCallMock.calledWith?.[1]).toEqual({
body: `{"description":"- [feat(great): implement great feature](http://gitlab.example.com/my-group/my-project/merge_requests/1) - [SPAR-156](https://my-ticket-management.com/view/SPAR-156)\\n- [feat(great): implement another great feature](http://gitlab.example.com/my-group/my-project/merge_requests/1) - [SPAR-158](https://my-ticket-management.com/view/SPAR-158)","tag_name":"${releaseTagName}","ref":"${pipelineFixture.sha}"}`,
body: `{"description":"- [feat(great): implement great feature](http://gitlab.example.com/my-group/my-project/-/merge_requests/1) - [SPAR-156](https://my-ticket-management.com/view/SPAR-156)\\n- [feat(great): implement another great feature](http://gitlab.example.com/my-group/my-project/-/merge_requests/1) - [SPAR-158](https://my-ticket-management.com/view/SPAR-158)","tag_name":"${releaseTagName}","ref":"${pipelineFixture.sha}"}`,
headers: { 'Content-Type': 'application/json' },
method: 'post',
});
Expand Down Expand Up @@ -607,8 +607,8 @@ describe('release > createRelease', () => {
text: {
text: `\
:homer: New release <${projectFixture.web_url}/-/releases/stable-19700101-0100|${releaseTagName}> for project <${projectFixture.web_url}|${projectFixture.path_with_namespace}>:
  • <http://gitlab.example.com/my-group/my-project/merge_requests/1|feat(great): implement great feature> - <https://my-ticket-management.com/view/SPAR-156|SPAR-156>
  • <http://gitlab.example.com/my-group/my-project/merge_requests/1|feat(great): implement another great feature> - <https://my-ticket-management.com/view/SPAR-158|SPAR-158>`,
  • <http://gitlab.example.com/my-group/my-project/-/merge_requests/1|feat(great): implement great feature> - <https://my-ticket-management.com/view/SPAR-156|SPAR-156>
  • <http://gitlab.example.com/my-group/my-project/-/merge_requests/1|feat(great): implement another great feature> - <https://my-ticket-management.com/view/SPAR-158|SPAR-158>`,
type: 'mrkdwn',
},
type: 'section',
Expand Down Expand Up @@ -762,7 +762,7 @@ wait for them and start the release automatically (<${pipelineFixture.web_url}|p
await waitFor(() => {
expect(releaseCallMock.called).toEqual(true);
expect(releaseCallMock.calledWith?.[1]).toEqual({
body: `{"description":"- [feat(great): implement great feature](http://gitlab.example.com/my-group/my-project/merge_requests/1) - [SPAR-156](https://my-ticket-management.com/view/SPAR-156)\\n- [feat(great): implement another great feature](http://gitlab.example.com/my-group/my-project/merge_requests/1) - [SPAR-158](https://my-ticket-management.com/view/SPAR-158)","tag_name":"${releaseTagName}","ref":"${pipelineFixture.sha}"}`,
body: `{"description":"- [feat(great): implement great feature](http://gitlab.example.com/my-group/my-project/-/merge_requests/1) - [SPAR-156](https://my-ticket-management.com/view/SPAR-156)\\n- [feat(great): implement another great feature](http://gitlab.example.com/my-group/my-project/-/merge_requests/1) - [SPAR-158](https://my-ticket-management.com/view/SPAR-158)","tag_name":"${releaseTagName}","ref":"${pipelineFixture.sha}"}`,
headers: { 'Content-Type': 'application/json' },
method: 'post',
});
Expand Down
2 changes: 1 addition & 1 deletion __tests__/utils/mockBuildReviewMessageCalls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function mockBuildReviewMessageCalls() {
const projectPath = url.pathname
.split('/')
.filter(Boolean)
.slice(0, -2)
.slice(0, -3)
.join('/');

mockGitlabCall(
Expand Down
2 changes: 1 addition & 1 deletion src/core/services/gitlab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ async function searchMergeRequestsByUrl(
const projectPath = url.pathname
.split('/')
.filter(Boolean)
.slice(0, -2)
.slice(0, -3)
.join('/');

return Promise.all([
Expand Down

0 comments on commit 14e74f4

Please sign in to comment.