+
Skip to content

Add repo.collaborators #304

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

Closed
wants to merge 4 commits into from
Closed

Conversation

timwis
Copy link
Contributor

@timwis timwis commented Mar 18, 2016

Added the ability to get a list of collaborators and check if a user is a collaborator per documentation. Note that for the life of me I can't get the tests to pass, even though the code works fine and the tests look like all the others. Figured I'd ask here before diving even further trying to debug the tests.

@AurelioDeRosa
Copy link
Member

Hi.

This method you've implemented follows (pretty much) an anti-pattern called Boolean trap. Based on a given Boolean value, the method changes its behavior. The behavior should be split in two methods, each with its own semantic. For example:

repo.collaborators()
repo.isCollaborator()

// -------

this.collaborators = function (username, cb) {
var command = repoPath + '/collaborators' + (username ? '/' + username : '')
Copy link
Member

Choose a reason for hiding this comment

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

Once you split the method in two there will be no need for this variable. You can use the string directly into the method call.

@timwis
Copy link
Contributor Author

timwis commented Mar 22, 2016

Thanks for the clarification @AurelioDeRosa - I was attempting to be consistent with the other methods in the library (ie. user.show) but I can see what you mean. I've separated out isCollaborator and updated the tests and documentation. I also verified that if you pass a falsy variable to isCollaborator's first paramter (username) github.com will still throw a 404, which is good.

@AurelioDeRosa
Copy link
Member

The tests were broken so I had to fix them. Apart from that, everything was good and the PR has been merged.

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

Successfully merging this pull request may close these issues.

2 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载