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

Fix CHANGE_AUTHOR and CHANGE_AUTHOR_DISPLAY_NAME #325

Merged
merged 5 commits into from
Jul 15, 2020

Conversation

jglick
Copy link
Member

@jglick jglick commented Jul 2, 2020

Fixes #195, which is not a plugin regression, but a cloud API regression to satisfy GDPR. There is apparently no way to set CHANGE_AUTHOR to the previous value. (CHANGE_FORK, or its first component if /-separated, is probably the same thing, though this is not necessarily the author.) Nor is CHANGE_AUTHOR_EMAIL possible.

Also, for Server, the display name was mistakenly being bound to the variable intended for the (code) username.

Example variables with BB Cloud, before:

(no variables starting with CHANGE_AUTHOR)

after:

CHANGE_AUTHOR=123456:some-long-uuid
CHANGE_AUTHOR_DISPLAY_NAME=Jesse Glick

With BB Server 7, before:

CHANGE_AUTHOR=Test User
CHANGE_AUTHOR_EMAIL=testuser@nowhere.net

and after:

CHANGE_AUTHOR=test-user
CHANGE_AUTHOR_DISPLAY_NAME=Test User
CHANGE_AUTHOR_EMAIL=testuser@nowhere.net

@jglick jglick marked this pull request as draft July 2, 2020 00:51
public Author(String username) {
this.username = username;
}

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public String getIdentifier() {
return identifier;
}

public void setIndentifier(String identifier) {
public void setIdentifier(String identifier) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines -73 to +81
if (this.pullRequest.getSource().getRepository().getOwnerName().equals(this.pullRequest.getAuthorLogin())) {
if (!this.pullRequest.getSource().getRepository().getOwnerName().equals(repository.getOwnerName())) { // i.e., a fork
BitbucketCloudRepositoryOwner owner = new BitbucketCloudRepositoryOwner();
owner.setUsername(this.pullRequest.getAuthorLogin());
owner.setDisplayName(this.pullRequest.getAuthorDisplayName());
owner.setUsername(this.pullRequest.getSource().getRepository().getOwnerName());
owner.setDisplayName(this.pullRequest.getAuthorLogin());
if (repository.isPrivate()) {
this.pullRequest.getSource().getRepository().setPrivate(repository.isPrivate());
}
this.pullRequest.getSource().getRepository().setOwner(owner);
} else if (this.pullRequest.getSource().getRepository().getOwnerName().equals(repository.getOwnerName())) {
} else { // origin branch
Copy link
Member Author

Choose a reason for hiding this comment

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

Possibly fixes a bug with the handling of webhooks for forked PRs in BB Cloud, though I am not sure how to test that outside a mock context (discovered due to unit test failures): I cannot find any non-test usages of BitbucketRepository.getOwner except for code in this reconstructMissingData method which sets an owner field. Perhaps @stephenc can clarify if he still remembers anything about it (but this was over three years ago).

@jglick jglick changed the title Make more information available in ContributorMetadataAction Fix CHANGE_AUTHOR and CHANGE_AUTHOR_DISPLAY_NAME Jul 2, 2020
@jglick jglick marked this pull request as ready for review July 2, 2020 17:21
Copy link
Member

@dwnusbaum dwnusbaum left a comment

Choose a reason for hiding this comment

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

Looks ok to me. The changes to the value of CHANGE_AUTHOR for Bitbucket Server should probably be called out in the release notes as a potential compatibility issue.

@jglick jglick mentioned this pull request Jul 13, 2020
@bitwiseman bitwiseman merged commit 1e2360c into jenkinsci:master Jul 15, 2020
@jglick jglick deleted the ContributorMetadataAction branch July 15, 2020 17:29
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.

CHANGE_AUTHOR variable not set
5 participants