Skip to content

Fix bug of sending the status in case of a merge request from fork #39

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

Open
wants to merge 1 commit into
base: Indore-2017.2.x
Choose a base branch
from

Conversation

LukinovD
Copy link

Fix bug of sending the status in case of a merge request from fork repository

@Frodox
Copy link

Frodox commented Jun 27, 2018

bump!

@karanagai
Copy link
Contributor

karanagai commented Jun 28, 2018

Hi @Frodox, we are currently reviewing the procedure of accepting pull requests into open source TeamCity plugins from legal perspective. Otherwise the fix seems to be useful and we are planning to accept it.

@karanagai
Copy link
Contributor

@LukinovD did I get it right that the credentials used by Commit Status Publisher should allow publishing statuses to the source project too?

@LukinovD
Copy link
Author

@karanagai, yes, it is true

MRInfoResponseProcessor processorMR = new MRInfoResponseProcessor();

try {
HttpHelper.get(url, null, null, Collections.singletonMap("PRIVATE-TOKEN", getPrivateToken()), BaseCommitStatusPublisher.DEFAULT_CONNECTION_TIMEOUT, processorMR);
Copy link
Contributor

Choose a reason for hiding this comment

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

The HTTP request is made synchronously within the CommitStatusPublisherListener event handlers execution. It may cause the control not to be returned to the code thatr calls these event handlers promptly enough, which is not desirable.

@@ -98,6 +107,28 @@ private void publish(@NotNull SBuild build,
throw new PublisherException("Cannot parse repository URL from VCS root " + root.getName());

String message = createMessage(status, build, revision, myLinks.getViewResultsUrl(build), description);

Pattern r = Pattern.compile("/merge-requests/([0-9]+)/");
Matcher m = r.matcher(revision.getRepositoryVersion().getVcsBranch());
Copy link
Contributor

@karanagai karanagai Sep 6, 2018

Choose a reason for hiding this comment

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

The return value of getVcsBranch() is marked as @Nullable


Pattern r = Pattern.compile("/merge-requests/([0-9]+)/");
Matcher m = r.matcher(revision.getRepositoryVersion().getVcsBranch());
if (m.find( )) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is minor, but worth noticing: GitLab branch name may contain slashes, so it seems using find() you in theory may match a branch name that is not a merge request, but its name just contain something that is matched by the pattern.

@fubar-coder
Copy link

@karanagai Is there a chance that you can merge this PR and fix those problems on your side? This is an annoying problem as more and more people use a self-hosted GitLab installation.

@versedi
Copy link

versedi commented Oct 8, 2019

Is there any estimation or a rejection of this feature?

This is kind of game-breaker for us with TeamCity and it seemed it would work out of the box. Unfortunately the most used fork-pull-merge can't be used with it.

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.

5 participants