-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[utils] Format all git domains, not only github.com #1058
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for your contribution!
Can you test case(s) for what you changed, and ensure the unit tests are passing?
You can find the existing tests here:
datadog-ci/src/helpers/__tests__/utils.test.ts
Lines 374 to 384 in 19a9e0c
describe('filterAndFormatGithubRemote', () => { | |
test('git remotes get formatted correctly', async () => { | |
expect(ciUtils.filterAndFormatGithubRemote('https:/datadog/test.git')).toEqual( | |
'github.com/datadog/test.git' | |
) | |
expect(ciUtils.filterAndFormatGithubRemote('[email protected]:datadog/test.git')).toEqual( | |
'github.com/datadog/test.git' | |
) | |
expect(ciUtils.filterAndFormatGithubRemote('github.com/datadog/test.git')).toEqual('github.com/datadog/test.git') | |
}) | |
}) |
@Drarig29 done |
src/helpers/__tests__/utils.test.ts
Outdated
@@ -380,6 +380,13 @@ describe('utils', () => { | |||
'github.com/datadog/test.git' | |||
) | |||
expect(ciUtils.filterAndFormatGithubRemote('github.com/datadog/test.git')).toEqual('github.com/datadog/test.git') | |||
expect(ciUtils.filterAndFormatGithubRemote('https://git.some.domain.com:8080/datadog/test.git')).toEqual( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would you remove the port? Do you have an example of scenario?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function is being used by serverless-datadog-plugin and colon symbol is a delimiter for key:value pair, had to remove port as well to fix
Co-authored-by: Corentin Girard <[email protected]>
src/helpers/__tests__/utils.test.ts
Outdated
expect(ciUtils.filterAndFormatGithubRemote('[email protected]:datadog/test.git')).toEqual( | ||
'test.domain.com/datadog/test.git' | ||
) | ||
expect(ciUtils.filterAndFormatGithubRemote('example.domain.com/datadog/test.git')).toEqual('example.domain.com/datadog/test.git') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are formatting all git domains, shouldn't we also change the function name (and jsdocs) to be something different than filterAndFormatGithubRemote
? Maybe just filterAndFormatGitRemote
? Just a nit, but would be better to keep consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've renamed it, but this function is exported, so some apps or libs, that depend on it can become broken
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AndrewChubatiuk good point!
Can you add the original filterAndFormatGithubRemote()
function back (with its old implementation and unit tests) and mark it as deprecated like that function?
Thanks in advance, and sorry for the delay!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added filterAndFormatGithubRemote() as alias to filterAndFormatGitRemote() and marked as deprecated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, indeed the unit test did not change, so the new implementation did not change in behavior for the old supported cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM – left a comment!
@AndrewChubatiuk I triggered the CI for your latest commit, and the lint phase fails. Running |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the contribution!
Hello @AndrewChubatiuk !
Out of curiosity, are you encountering an issue with the current version ? For context, this normalization for GitHub URLs was introduced to circumvent some limitations around some old tracer versions that don't support the URL scheme in tags, but it shouldn't be necessary in most cases now. For GitHub repositories, the |
@rpelliard this function is being used by |
@AndrewChubatiuk What version of serverless-plugin-datadog, and which language are you using ? The latest one should only bundle versions of the tracing libraries that support the double columns in the tags |
What and why?
Enabled formatting of all git remotes, not only github.com to fix datadog serverless plugin tags, while using in projects with repos that are not hosted on github
How?
updated regular expression to replace fix remote urls with any domain name