-
Notifications
You must be signed in to change notification settings - Fork 81
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
fix: file labels in GitLab releases, to ensure they're unique. #267
base: master
Are you sure you want to change the base?
Conversation
b33ed93
to
9be4ada
Compare
The force pushes are all commit message. I linked it to the issues and fixed some typos. |
It may be worth documenting too, but you would use this feature like this
Now all things found in |
Previously GitLab lables were just the basename for files uploaded as part of the release. This is problematic because GitLab doesn't allow conflicting labels -- a condition that could be caused by uploading a release with two files by the same name in different directories. This would generate a 409 Conflict error. This changes the labels for files uploaded as part of a release to the name relative to pkgRoot, or the package. A project may look like this pkg pkg \ foo \ baz pkg \ bar \ baz This would previously result in two conflicting labels of 'baz'. Now you would have {"foo/baz", "bar/baz"} with no conflict. GitHub issues: semantic-release#265, semantic-release#158
bc284ca
to
04f20f2
Compare
I rebased this can I get some input on it? |
This PR has been stale for nearly two years now, so I'm closing it. Feel free to send a new PR if you want this 🙇 |
It was stale because you never gave any input on it lol. Despite being asked by others in the same issues #265 (comment) |
Ha wow, too ambitious in cleaning up. Sorry! @EvanCarroll I'll review tomorrow or early next week. Can you rebase once more? 🙇 |
@@ -42,7 +41,7 @@ module.exports = async ({cwd}, assets) => | |||
// - `filepath` ignored (also to avoid duplicates) | |||
// - other properties of the original asset definition | |||
const {filepath, ...others} = asset; | |||
return globbed.map(file => ({...others, path: file, label: basename(file)})); | |||
return globbed.map(file => ({...others, path: file, label: path.relative(pkgRoot || '.', file)})); |
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.
Should we consider this a breaking change?
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.
@fgreinacher I wouldn't unless generating duplicate labels was support somewhere and things depended o nit. Honestly don't know. Seems weird. Imagine creating a listing of files in multiple directories and losing the directory they were in, that was the old behavior. So the labels would collide and the SCM would reject the operation.
@@ -31,6 +29,7 @@ module.exports = ( | |||
: 'https://gitlab.com'); | |||
|
|||
return { | |||
pkgRoot, |
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 understand you are mirroring the NPM plugin here, but the concept of a package does not really exist for the GitLab plugin.
What about assetBasePath
or assetRootPath
?
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.
Also please add some documentation 🙇
@@ -224,6 +234,7 @@ test('Ignore GitLab CI/CD environment variables if not running on GitLab CI/CD', | |||
gitlabApiUrl: urlJoin('https://gitlab.com', '/api/v4'), | |||
assets: undefined, | |||
milestones: undefined, | |||
pkgRoot: undefined, | |||
} | |||
); | |||
}); |
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.
Can you add some test cases for the new option? Especially weird cases like when the asset is not within the base/root path or when the base/root path is somehow malformed/does not exist.
module.exports = async ({pkgRoot, cwd}, assets) => { | ||
return uniqWith( |
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 can stay an arrow function, no?
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.
@fgreinacher I'm confused. It's still an arrow function
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.
Thanks @EvanCarroll and sorry that I somewhat missed that this is ready for review.
I left some comments :)
@EvanCarroll Do you still want to tackle this? If not someone else could take over. |
@EvanCarroll shall somebody else take over for you or do you want to continue here? |
I think somebody else needs to take over here. |
Please, take it over. I'm not adding tests for this. If you want to add tests to a project that didn't previously have them, that's another issue imho. Besides I have to maintain a forks of all of the bugs I've fixed in the semantic-release projects anyway. |
Previously GitLab lables were just the basename for files uploaded as
part of the release. This is problematic because GitLab doesn't allow
conflicting labels -- a condition that could be caused by uploading a
release with two files by the same name in different directories. This
would generate a 409 Conflict error.
This changes the labels for files uploaded as part of a release to the
name relative to pkgRoot, or the package.
A project may look like this
pkg
pkg \ foo \ baz
pkg \ bar \ baz
This would previously result in two conflicting labels of 'baz'. Now you
would have {"foo/baz", "bar/baz"} with no conflict.
GitHub issues: #265, #158