Skip to content
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

Use PROJECT_ID instead of PROJECT_PATH in Gitlab urls #1478

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

simonfelding
Copy link

This PR fixes a bug where danger would not work with (some?) self-hosted instances.

Before this patch, I got a 404 from our self-hosted Gitlab CE API. Now it works as expected.

It also fixes issues like #968 because the problem is deriving a valid URL for the project. Since PROJECT_ID is unique on a gitlab instance, you can always just use that instead of the PROJECT_PATH.

I tested this and it works. I'm not sure how to run tests in ruby locally, so CI will probably fail.

@simonfelding
Copy link
Author

I have the same patch ready for danger-js, if this one is acceptable.

Copy link
Member

@manicmaniac manicmaniac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix a test cases in spec/lib/danger/ci_sources/gitlab_ci_spec.rb.
It seems to use CI_MERGE_REQUEST_PROJECT_PATH.

BTW you can run specs locally with the following command.

bundle install
bundle exec rake spec

@@ -11,7 +11,7 @@
## master

<!-- Your comment below here -->
* Add keyword arguments to MessageAggregator.aggregate for Ruby 3.X compatibility - [@dirtyhabits97](https://github.com/dirtyhabits97) [#1466](https://github.com/danger/danger/pull/1466)
* Use PROJECT_ID instead of PROJECT_PATH in Gitlab urls. This fixes a bug where Danger would not work with Gitlab self-hosted instances. - [@simonfelding](https://github.com/simonfelding) [#1478](https://github.com/danger/danger/pull/1478)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not delete the old one, just append a new entry.

@@ -42,7 +42,7 @@ def self.determine_pull_or_merge_request_id(env)
return env["CI_EXTERNAL_PULL_REQUEST_IID"] if env["CI_EXTERNAL_PULL_REQUEST_IID"]
return 0 unless env["CI_COMMIT_SHA"]

project_path = env["CI_MERGE_REQUEST_PROJECT_PATH"] || env["CI_PROJECT_PATH"]
project_path = env["CI_MERGE_REQUEST_PROJECT_ID"] || env["CI_PROJECT_ID"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the variable project_path should be renamed as well.

Copy link
Member

@manicmaniac manicmaniac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me change review status to request changes until the issues are resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants