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

get project's owners and permissions of various users #101

Merged
merged 5 commits into from
Jul 12, 2019

Conversation

marusinm
Copy link
Contributor

@marusinm marusinm commented Jul 8, 2019

Implementation of getting project owners related to #88.
And getting users with permission for closing Issues and merging PR based on Github permissions and Pagure permissions related to issue #100.

@packit-as-a-service

This comment has been minimized.

@packit-as-a-service
Copy link

Congratulations! The build has finished successfully. 🍾

You can install the built RPMs by following these steps:

  • sudo yum install -y dnf-plugins-core on RHEL 8
  • sudo dnf install -y dnf-plugins-core on Fedora
  • dnf copr enable packit/packit-service-ogr-101
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

Copy link
Member

@lachmanfrantisek lachmanfrantisek left a comment

Choose a reason for hiding this comment

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

Nice work!

Just a few notes.

owners = []
owner = self.github_repo.owner
owners.append(owner.login)
return owners
Copy link
Member

Choose a reason for hiding this comment

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

This can be done in one line, but leave it as is if you think it is more clear now.

return [self.github_repo.owner]

for username, persmission in collaborators.items():
if persmission == "admin" or persmission == "write":
usernames.append(username)
return usernames
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it possible to close an issue created by myself even if I cannot do that on other issues?

(In that case, we need this method also in the Issue class as it is issue-related.)

Do it in the way it is useful for you in the release-bot..;-)

usernames = []
collaborators = self._get_collaborators_with_permission()
for username, persmission in collaborators.items():
if persmission == "admin" or persmission == "write":
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if persmission == "admin" or persmission == "write":
if persmission in ["admin", "write"]:

def who_can_close_issue(self) -> List[str]:
usernames = []
collaborators = self._get_collaborators_with_permission()
for username, persmission in collaborators.items():
Copy link
Member

Choose a reason for hiding this comment

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

just typo: s/persmission/permission

for user in users:
permission = self.github_repo.get_collaborator_permission(user)
collaborators[user.login] = permission
# collaborators.append(user.login)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# collaborators.append(user.login)

return project["access_users"]["owner"]

def who_can_close_issue(self) -> List[str]:
users: Set[str] = set()
Copy link
Member

Choose a reason for hiding this comment

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

What about returning set for all methods (github/pagure/abstract)?

@lachmanfrantisek lachmanfrantisek added kind/feature New feature or a request for enhancement. area/github Related to GitHub implementation. pagure Related to Pagure implementation. labels Jul 9, 2019
@packit-as-a-service
Copy link

Congratulations! The build has finished successfully. 🍾

You can install the built RPMs by following these steps:

  • sudo yum install -y dnf-plugins-core on RHEL 8
  • sudo dnf install -y dnf-plugins-core on Fedora
  • dnf copr enable packit/packit-service-ogr-101
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

@marusinm
Copy link
Contributor Author

marusinm commented Jul 10, 2019

Isn't it possible to close an issue created by myself even if I cannot do that on other issues?

@lachmanfrantisek I completely changed the approach from the previous commit how to get user permissions. For example, I changed fnc who_can_close_issue() -> List[users] to can_close_issue(user, issue) -> bool. Using these new functions should be more straightforward and a user can close his issue even if he cannot do that on other issues.

I also change tests from previous commit and their yaml files.

@packit-as-a-service
Copy link

Congratulations! The build has finished successfully. 🍾

You can install the built RPMs by following these steps:

  • sudo yum install -y dnf-plugins-core on RHEL 8
  • sudo dnf install -y dnf-plugins-core on Fedora
  • dnf copr enable packit/packit-service-ogr-101
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

)
return False

for login, permission in collaborators.items():
Copy link
Member

Choose a reason for hiding this comment

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

Personally, I would like to see also the list/set of allowed users. (Since you are going through all of the collaborators and we are not saving any time with that.)

We have following possibilities:

  1. who_can_close_issues and can_close_issue (which will use who_can_close_issues and checks the author of the issue) (We can move the can_close_issue to the Issue object later.)
  2. who_can_close_issue with the optional parameter for specifying the issue id
  3. leave it in the current state

I vote for the second one but make your own decision...;-)

(Same for the pull-requests.)

Copy link
Contributor

@rpitonak rpitonak left a comment

Choose a reason for hiding this comment

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

Nice work! I am going to merge, but feel free to continue the discussion if you find something.

@rpitonak rpitonak merged commit badeddd into packit:master Jul 12, 2019
Copy link
Member

@lachmanfrantisek lachmanfrantisek left a comment

Choose a reason for hiding this comment

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

Rado was quicker than me but I have only two notes.

I've not tested that but we have tests for it and you will realise possible problems in the ReleaseBot.


for allowed_user in allowed_users:
if username == allowed_user:
return True
Copy link
Member

Choose a reason for hiding this comment

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

What about this:

if username in allowed_users:
    return True


for allowed_user in allowed_users:
if username == allowed_user:
return True
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/github Related to GitHub implementation. kind/feature New feature or a request for enhancement. pagure Related to Pagure implementation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants