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

🐛 Add a workaround for organisations in GitLab #4415

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

verm
Copy link

@verm verm commented Nov 18, 2024

This fixes Contributors.

Currently organisations are an experimental features in GitLab this change makes it use the users email domain as a pseudo organisation. The domains are anonymised as these are printed as part of the report and shouldn't be exposed.

It's uncertain if the uptake in organisation will be large considering GitLab users are used to using groups for this purpose.

What kind of change does this PR introduce?

Fixes a bug where Contributors were always set to 0 I did not see an open issue for this.

What is the current behavior?

Contributors will always be 0.

What is the new behavior (if this is a feature change)?**

  • Tests for the changes have been added (for bug fixes/features)

Which issue(s) this PR fixes

NONE

Special notes for your reviewer

What I've done here is used the email domains as a pseudo orginisation and anonymomised it using the slice index as gitlab-N. This lets Contributors give somewhat useful data and in the future when Orginisation is no longer experimental we'll be able to remove this. I found this to be the least invasive method of handling the situation.

Does this PR introduce a user-facing change?

NONE

Fix Contributors to return somewhat useful data for GitLab.

This fixes Contributors.

Currently organisations are an experimental features in GitLab this change makes
it use the users email domain as a pseudo organisation.  The domains are
anonymised as these are printed as part of the report and shouldn't be exposed.

It's uncertain if the uptake in organisation will be large considering GitLab
users are used to using groups for this purpose.

Signed-off-by: Amar Takhar <[email protected]>
@verm verm requested a review from a team as a code owner November 18, 2024 05:46
@verm verm requested review from justaugustus and spencerschrock and removed request for a team November 18, 2024 05:46
Copy link
Contributor

@raghavkaul raghavkaul left a comment

Choose a reason for hiding this comment

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

Email domains aren't indicative of an organization that a contributor belongs to. Is there any other API feature we can use to get contributor organizations?

*orgDomain = append(*orgDomain, orgName)

// Search for domain and use index as unique marker
for i, domain := range *orgDomain {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider slices.Index.

Copy link
Author

Choose a reason for hiding this comment

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

Not sure how to leverage that to get what I need do you have an example? Thank you.

// pointer to maintain list of domains and email returns an anonymised
// string with the slice index as a unique identifier.
// Pointer is required as we are modifying the slice length.
func getOrginisation(orgDomain *[]string, orgReal string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be in clients/gitlabrepo/commits.go since we're dealing with commit email addresses.

Copy link
Author

Choose a reason for hiding this comment

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

I did not put that there since this should only be a temporary measure and this is specific to GitLab if you want me to move it after happy to do so.

@verm
Copy link
Author

verm commented Nov 19, 2024

Email domains aren't indicative of an organization that a contributor belongs to. Is there any other API feature we can use to get contributor organizations?

Orginisations in GitLab are an experimental feature with no interface other than the API to get to it. There is no other unique identifier. I agree that it's not ideal nore a good indicator the only other option is to remove it completely but this at least gives us something that may be useful.

I did it this way as it seemed the least invasive to support this until Orginisation is settled as a public feature.

@raghavkaul
Copy link
Contributor

We use the Users API to get the Organization, not the Organizations API. As I understand it, it's just the API that's experimental, and Organizations are part of GitLab to stay.

@verm
Copy link
Author

verm commented Nov 19, 2024

We use the Users API to get the Organization, not the Organizations API. As I understand it, it's just the API that's experimental, and Organizations are part of GitLab to stay.

Yes they are here to stay the way GitLab wants you to set them up is using groups which don't exist in GitHub. If you go to GitLab docs they just want you to setup groups -- this is not what the API being used is it's an entirely new concept for Orginizations similar to how GitHub has them.

The concept of 'orginization' does not exist in GitLab yet it is only exposed via an API and it's all experimental.

This is why in nearly every case using this API right now is going to return an empty string. The web UI isn't even enabled for it:

To summerise: The only way you're going to get a user with an orgnization is if you enable experimental flags and use the API directly. It won't show up anywhere on the web UI nore can you edit it. You can also see here that all of the feature flags are disabled by default for orginization:

@spencerschrock
Copy link
Member

organisations are an experimental features in GitLab

considering GitLab users are used to using groups for this purpose.

Would it be better to use groups then?

e.g if a user is in group foo/bar/baz, then they're a part of "organization" foo?

@verm
Copy link
Author

verm commented Nov 27, 2024

e.g if a user is in group foo/bar/baz, then they're a part of "organization" foo?

The problem with this is groups are used for organising permissions. While some may use it in that way there are plenty that don't look at RTEMS for example:

I think it will be years until Orgs in GitLab will be used in the same way as GitHub. I'd argue at least email domains being no worse than using groups but my original point is valid. Orgs are coming to GitLab and this is just a temp measure and the ones that causes the least churn since we are running these queries anyway.

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

Successfully merging this pull request may close these issues.

3 participants