From e9269b515e09be38b9966a9fde8c07923f77f3c8 Mon Sep 17 00:00:00 2001 From: Mehul Kiran Chaudhari <55375534+MehulKChaudhari@users.noreply.github.com> Date: Fri, 17 Jan 2025 00:47:00 +0530 Subject: [PATCH 01/11] fix: ember-source broken links --- app/helpers/github-link.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/helpers/github-link.js b/app/helpers/github-link.js index c23247d6..e4992cef 100644 --- a/app/helpers/github-link.js +++ b/app/helpers/github-link.js @@ -2,10 +2,15 @@ import { helper } from '@ember/component/helper'; import githubMap, { mainDir } from '../utils/github-map'; export function githubLink([project, version, file, line], { isEdit = false }) { + // Adjust version if it's a `v6.0.x` pattern to match the Git tags + const adjustedVersion = version.startsWith('v6.0.') + ? `${version}-ember-source` + : version; + if (isEdit) { return `https://github.com/${githubMap[project]}/edit/release${mainDir( project, - version + adjustedVersion )}${file}#L${line}`; } @@ -22,9 +27,9 @@ export function githubLink([project, version, file, line], { isEdit = false }) { // 'https://github.com/emberjs/data/tree/v4.10.0/packages/packages/store/addon/-private/record-arrays/identifier-array.ts#L118' const fixedFile = file?.replace('../packages/', '../'); - return `https://github.com/${githubMap[project]}/tree/v${version}${mainDir( + return `https://github.com/${githubMap[project]}/tree/${adjustedVersion}${mainDir( project, - version + adjustedVersion )}${fixedFile}#L${line}`; } From d0a2c0457d3b2ab4defa2ffb54734b0ea1328851 Mon Sep 17 00:00:00 2001 From: Mehul Kiran Chaudhari <55375534+MehulKChaudhari@users.noreply.github.com> Date: Fri, 17 Jan 2025 01:28:24 +0530 Subject: [PATCH 02/11] feat: extend the logic to add suffix for all the major versions greater than equal 6 --- app/helpers/github-link.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/helpers/github-link.js b/app/helpers/github-link.js index e4992cef..cca677b0 100644 --- a/app/helpers/github-link.js +++ b/app/helpers/github-link.js @@ -2,8 +2,11 @@ import { helper } from '@ember/component/helper'; import githubMap, { mainDir } from '../utils/github-map'; export function githubLink([project, version, file, line], { isEdit = false }) { - // Adjust version if it's a `v6.0.x` pattern to match the Git tags - const adjustedVersion = version.startsWith('v6.0.') + const isEmberProject = project === 'ember'; + const majorVersion = parseInt(version.split('.')[0].replace('v', ''), 10); + + // Check if the project is 'ember' and adjust the tag only if the major version is >= 6 to match the Git tags + const adjustedVersion = isEmberProject && majorVersion >= 6 ? `${version}-ember-source` : version; From 171bad5de86879da995277622bb505cc66dc6c8c Mon Sep 17 00:00:00 2001 From: Mehul Kiran Chaudhari <55375534+MehulKChaudhari@users.noreply.github.com> Date: Fri, 17 Jan 2025 01:44:17 +0530 Subject: [PATCH 03/11] fix: lint --- app/helpers/github-link.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/helpers/github-link.js b/app/helpers/github-link.js index cca677b0..28eecd1b 100644 --- a/app/helpers/github-link.js +++ b/app/helpers/github-link.js @@ -6,8 +6,8 @@ export function githubLink([project, version, file, line], { isEdit = false }) { const majorVersion = parseInt(version.split('.')[0].replace('v', ''), 10); // Check if the project is 'ember' and adjust the tag only if the major version is >= 6 to match the Git tags - const adjustedVersion = isEmberProject && majorVersion >= 6 - ? `${version}-ember-source` + const adjustedVersion = + isEmberProject && majorVersion >= 6 ? `${version}-ember-source` : version; if (isEdit) { @@ -30,7 +30,9 @@ export function githubLink([project, version, file, line], { isEdit = false }) { // 'https://github.com/emberjs/data/tree/v4.10.0/packages/packages/store/addon/-private/record-arrays/identifier-array.ts#L118' const fixedFile = file?.replace('../packages/', '../'); - return `https://github.com/${githubMap[project]}/tree/${adjustedVersion}${mainDir( + return `https://github.com/${ + githubMap[project] + }/tree/${adjustedVersion}${mainDir( project, adjustedVersion )}${fixedFile}#L${line}`; From 0ab7ccc5b7fb4d861f062c9722eef54ee5e36245 Mon Sep 17 00:00:00 2001 From: Mehul Kiran Chaudhari <55375534+MehulKChaudhari@users.noreply.github.com> Date: Fri, 17 Jan 2025 02:13:46 +0530 Subject: [PATCH 04/11] fix: lint and tag --- app/helpers/github-link.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/helpers/github-link.js b/app/helpers/github-link.js index 28eecd1b..fff6f795 100644 --- a/app/helpers/github-link.js +++ b/app/helpers/github-link.js @@ -7,8 +7,7 @@ export function githubLink([project, version, file, line], { isEdit = false }) { // Check if the project is 'ember' and adjust the tag only if the major version is >= 6 to match the Git tags const adjustedVersion = - isEmberProject && majorVersion >= 6 ? `${version}-ember-source` - : version; + isEmberProject && majorVersion >= 6 ? `v${version}-ember-source` : `v${version}`; if (isEdit) { return `https://github.com/${githubMap[project]}/edit/release${mainDir( From 19c6627c7300e8826e166155740578f43cf542bf Mon Sep 17 00:00:00 2001 From: Mehul Kiran Chaudhari <55375534+MehulKChaudhari@users.noreply.github.com> Date: Fri, 17 Jan 2025 02:17:13 +0530 Subject: [PATCH 05/11] fix: ensure v is prefix always --- app/helpers/github-link.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/github-link.js b/app/helpers/github-link.js index fff6f795..a8b1568b 100644 --- a/app/helpers/github-link.js +++ b/app/helpers/github-link.js @@ -5,9 +5,11 @@ export function githubLink([project, version, file, line], { isEdit = false }) { const isEmberProject = project === 'ember'; const majorVersion = parseInt(version.split('.')[0].replace('v', ''), 10); + const baseVersion = `v${version.replace(/^v/, '')}`; + // Check if the project is 'ember' and adjust the tag only if the major version is >= 6 to match the Git tags const adjustedVersion = - isEmberProject && majorVersion >= 6 ? `v${version}-ember-source` : `v${version}`; + isEmberProject && majorVersion >= 6 ? `${baseVersion}-ember-source` : baseVersion; if (isEdit) { return `https://github.com/${githubMap[project]}/edit/release${mainDir( @@ -29,9 +31,7 @@ export function githubLink([project, version, file, line], { isEdit = false }) { // 'https://github.com/emberjs/data/tree/v4.10.0/packages/packages/store/addon/-private/record-arrays/identifier-array.ts#L118' const fixedFile = file?.replace('../packages/', '../'); - return `https://github.com/${ - githubMap[project] - }/tree/${adjustedVersion}${mainDir( + return `https://github.com/${githubMap[project]}/tree/${adjustedVersion}${mainDir( project, adjustedVersion )}${fixedFile}#L${line}`; From 62baf8e381a0088d33ddcb6f8b0d84100c0a2c1d Mon Sep 17 00:00:00 2001 From: Mehul Kiran Chaudhari <55375534+MehulKChaudhari@users.noreply.github.com> Date: Fri, 17 Jan 2025 02:28:01 +0530 Subject: [PATCH 06/11] fix: tests --- app/helpers/github-link.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/helpers/github-link.js b/app/helpers/github-link.js index a8b1568b..b410e277 100644 --- a/app/helpers/github-link.js +++ b/app/helpers/github-link.js @@ -3,13 +3,15 @@ import githubMap, { mainDir } from '../utils/github-map'; export function githubLink([project, version, file, line], { isEdit = false }) { const isEmberProject = project === 'ember'; - const majorVersion = parseInt(version.split('.')[0].replace('v', ''), 10); + const majorVersion = parseInt(version?.split('.')[0].replace('v', ''), 10); const baseVersion = `v${version.replace(/^v/, '')}`; // Check if the project is 'ember' and adjust the tag only if the major version is >= 6 to match the Git tags const adjustedVersion = - isEmberProject && majorVersion >= 6 ? `${baseVersion}-ember-source` : baseVersion; + isEmberProject && majorVersion >= 6 + ? `${baseVersion}-ember-source` + : baseVersion; if (isEdit) { return `https://github.com/${githubMap[project]}/edit/release${mainDir( @@ -31,7 +33,9 @@ export function githubLink([project, version, file, line], { isEdit = false }) { // 'https://github.com/emberjs/data/tree/v4.10.0/packages/packages/store/addon/-private/record-arrays/identifier-array.ts#L118' const fixedFile = file?.replace('../packages/', '../'); - return `https://github.com/${githubMap[project]}/tree/${adjustedVersion}${mainDir( + return `https://github.com/${ + githubMap[project] + }/tree/${adjustedVersion}${mainDir( project, adjustedVersion )}${fixedFile}#L${line}`; From 312e962272ecd7718cc570066768d0ac00ff27df Mon Sep 17 00:00:00 2001 From: Mehul Kiran Chaudhari <55375534+MehulKChaudhari@users.noreply.github.com> Date: Fri, 17 Jan 2025 02:34:57 +0530 Subject: [PATCH 07/11] add: tests --- app/helpers/github-link.js | 4 ++-- tests/unit/helpers/github-link-test.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/helpers/github-link.js b/app/helpers/github-link.js index b410e277..c61e7862 100644 --- a/app/helpers/github-link.js +++ b/app/helpers/github-link.js @@ -10,8 +10,8 @@ export function githubLink([project, version, file, line], { isEdit = false }) { // Check if the project is 'ember' and adjust the tag only if the major version is >= 6 to match the Git tags const adjustedVersion = isEmberProject && majorVersion >= 6 - ? `${baseVersion}-ember-source` - : baseVersion; + ? `${baseVersion}-ember-source` + : baseVersion; if (isEdit) { return `https://github.com/${githubMap[project]}/edit/release${mainDir( diff --git a/tests/unit/helpers/github-link-test.js b/tests/unit/helpers/github-link-test.js index f8ea0352..e6b0c38f 100644 --- a/tests/unit/helpers/github-link-test.js +++ b/tests/unit/helpers/github-link-test.js @@ -13,6 +13,17 @@ module('Unit | Helper | github link', function () { ); }); + test('should append "ember-source" to the version for git tags v6 and above', function (assert) { + let result = githubLink( + ['ember', '6.0.0', 'ember-glimmer/lib/component.js', '35'], + {} + ); + assert.equal( + result, + 'https://github.com/emberjs/ember.js/tree/v6.0.0-ember-source/ember-glimmer/lib/component.js#L35' + ); + }); + test('should render a github link for ember-data from file info', function (assert) { let result = githubLink( ['ember-data', '2.10.0', 'addon/-private/adapters/errors.js', '10'], From a9711eb24acd2b16c606cffd78fde2e7def1fbfb Mon Sep 17 00:00:00 2001 From: Mehul Kiran Chaudhari <55375534+MehulKChaudhari@users.noreply.github.com> Date: Sun, 19 Jan 2025 10:45:53 +0530 Subject: [PATCH 08/11] fix: handle version is empy --- app/helpers/github-link.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/github-link.js b/app/helpers/github-link.js index c61e7862..282f2b59 100644 --- a/app/helpers/github-link.js +++ b/app/helpers/github-link.js @@ -5,7 +5,7 @@ export function githubLink([project, version, file, line], { isEdit = false }) { const isEmberProject = project === 'ember'; const majorVersion = parseInt(version?.split('.')[0].replace('v', ''), 10); - const baseVersion = `v${version.replace(/^v/, '')}`; + const baseVersion = version ? `v${version.replace(/^v/, '')}` : 'main'; // Check if the project is 'ember' and adjust the tag only if the major version is >= 6 to match the Git tags const adjustedVersion = From a98020c0b014f4808c9a2700a1a9e9927863eca7 Mon Sep 17 00:00:00 2001 From: Mehul Kiran Chaudhari <55375534+MehulKChaudhari@users.noreply.github.com> Date: Sun, 19 Jan 2025 11:09:01 +0530 Subject: [PATCH 09/11] refactor: remove extra baseversion line --- app/helpers/github-link.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/helpers/github-link.js b/app/helpers/github-link.js index 282f2b59..f515e2e2 100644 --- a/app/helpers/github-link.js +++ b/app/helpers/github-link.js @@ -5,13 +5,11 @@ export function githubLink([project, version, file, line], { isEdit = false }) { const isEmberProject = project === 'ember'; const majorVersion = parseInt(version?.split('.')[0].replace('v', ''), 10); - const baseVersion = version ? `v${version.replace(/^v/, '')}` : 'main'; - // Check if the project is 'ember' and adjust the tag only if the major version is >= 6 to match the Git tags const adjustedVersion = isEmberProject && majorVersion >= 6 - ? `${baseVersion}-ember-source` - : baseVersion; + ? `${version}-ember-source` + : version; if (isEdit) { return `https://github.com/${githubMap[project]}/edit/release${mainDir( @@ -35,7 +33,7 @@ export function githubLink([project, version, file, line], { isEdit = false }) { return `https://github.com/${ githubMap[project] - }/tree/${adjustedVersion}${mainDir( + }/tree/v${adjustedVersion}${mainDir( project, adjustedVersion )}${fixedFile}#L${line}`; From 6c34280b332d53370bee069293e859a663c8ad8a Mon Sep 17 00:00:00 2001 From: Mehul Kiran Chaudhari <55375534+MehulKChaudhari@users.noreply.github.com> Date: Sun, 19 Jan 2025 11:11:47 +0530 Subject: [PATCH 10/11] fix: lint --- app/helpers/github-link.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/helpers/github-link.js b/app/helpers/github-link.js index f515e2e2..ecf12788 100644 --- a/app/helpers/github-link.js +++ b/app/helpers/github-link.js @@ -7,8 +7,7 @@ export function githubLink([project, version, file, line], { isEdit = false }) { // Check if the project is 'ember' and adjust the tag only if the major version is >= 6 to match the Git tags const adjustedVersion = - isEmberProject && majorVersion >= 6 - ? `${version}-ember-source` + isEmberProject && majorVersion >= 6 ? `${version}-ember-source` : version; if (isEdit) { From b0bea2853a1ee8658ef5178dd4aa2804f471ba9b Mon Sep 17 00:00:00 2001 From: Mehul Kiran Chaudhari <55375534+MehulKChaudhari@users.noreply.github.com> Date: Sun, 19 Jan 2025 11:13:17 +0530 Subject: [PATCH 11/11] fix: lint --- app/helpers/github-link.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/helpers/github-link.js b/app/helpers/github-link.js index ecf12788..afc0786b 100644 --- a/app/helpers/github-link.js +++ b/app/helpers/github-link.js @@ -7,8 +7,7 @@ export function githubLink([project, version, file, line], { isEdit = false }) { // Check if the project is 'ember' and adjust the tag only if the major version is >= 6 to match the Git tags const adjustedVersion = - isEmberProject && majorVersion >= 6 ? `${version}-ember-source` - : version; + isEmberProject && majorVersion >= 6 ? `${version}-ember-source` : version; if (isEdit) { return `https://github.com/${githubMap[project]}/edit/release${mainDir(