Skip to content

Add Support For GitData Reference Matching Methods - #875

Merged
acrobat merged 9 commits into
KnpLabs:masterfrom
nickpoulos:add-data-ref-matching-methods
May 18, 2020
Merged

Add Support For GitData Reference Matching Methods#875
acrobat merged 9 commits into
KnpLabs:masterfrom
nickpoulos:add-data-ref-matching-methods

Conversation

@nickpoulos

Copy link
Copy Markdown
Contributor

This PR adds two methods - matchingBranch() and matchingTag() to GitHub/Api/GitData/References.php. These methods return the references for a given branch or tag, respectively.

There are two more tests to GitHub/Tests/Api/GitData/ReferencesTest.php, shouldGetAllMatchingBranchRepoReferences and shouldGetAllMatchingTagRepoReferences.

Documentation here: https://developer.github.com/v3/git/refs/#list-matching-references

Added two new methods to GitData->References to cover the matching reference endpoints described here:

https://developer.github.com/v3/git/refs/#list-matching-references
Add New Tests In ReferencesTest For Our Two New Methods

@acrobat acrobat left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the PR @nickpoulos! I have just a few small comments.

Comment thread lib/Github/Api/GitData/References.php Outdated
Comment thread lib/Github/Api/GitData/References.php Outdated
Comment thread lib/Github/Api/GitData/References.php Outdated
Comment thread lib/Github/Api/GitData/References.php Outdated
- Add rawurlencode around both the $branch and $tag parameters in matchingBranch() and matchingTag() respectively.
- Add parameter type hints, and function return types for both marchingBranch() and matchingTag()
@nickpoulos
nickpoulos requested a review from acrobat May 15, 2020 21:51

@acrobat acrobat left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good @nickpoulos! One thing I forgot to mention, can you add a docs entry for the newly added endpoints?

After that it's good to be merged!

@nickpoulos

Copy link
Copy Markdown
Contributor Author

Sure thing, let me write something up I'll get it in there later tonight. Thanks man

@nickpoulos

Copy link
Copy Markdown
Contributor Author

Hmm, after writing the docs, I am wondering if I am not quite sticking to conventions the package has set. For example to show a reference, based on a tag or branch, you must include the either 'head/' or 'tag/' as part of the last argument, like so:

Show a reference

$reference = $client->api('gitData')->references()->show('KnpLabs', 'php-github-api', 'heads/featureA');

The last argument contains both '/head/'and the branch name, and would contain 'tag/' and a tag name for tags, so they can use one endpoint and method for both tag/branch. I have abstracted that out into two methods, where you don't prefix 'head/' or 'tag/' in your third argument.

I am suggesting I rewrite to a singular method as the rest of the package appears to do.

Add Documentation For method matching() in gitdata/references.md
- In order to match existing API conventions, the two method solution for branch/tag was consolidated into one method and extra data in the third argument.

- Updated ReferencesTest.php to only test the single method
Remove link from DocBlock
@nickpoulos
nickpoulos requested a review from acrobat May 17, 2020 06:24
Comment thread lib/Github/Api/GitData/References.php Outdated
@acrobat

acrobat commented May 17, 2020

Copy link
Copy Markdown
Collaborator

Can you also fix the styleci issue? (I know it's a nitpick but this will let all pr checks pass before I merge 😄)

- reference parameters for the API can contain a '/', luckily we already have a method to handle these cases
@nickpoulos

Copy link
Copy Markdown
Contributor Author

Can you also fix the styleci issue? (I know it's a nitpick but this will let all pr checks pass before I merge 😄)

Yea I noticed this, and I would love to fix it. But when I click on the StyleCI details it gives me a very generic error:

Issues have been identified

And then I can't seem to find any more information. When I examine the code it pointed out as incorrect, nothing glaring jumps out at me? Any ideas there? Sorry if this is another easy one, my StyleCI-foo is prob not up to snuff.

Comment thread lib/Github/Api/GitData/References.php Outdated
}

/**
* Get all matching references for the supplied reference name

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@nickpoulos this is the line where styleci "complains" about. It should end with a "."

Update ReferencesTest.php To Use A More Realistic Parameter
StyleCI Add Period
@nickpoulos
nickpoulos requested a review from acrobat May 18, 2020 12:52
@acrobat
acrobat merged commit 11b683c into KnpLabs:master May 18, 2020
@acrobat

acrobat commented May 18, 2020

Copy link
Copy Markdown
Collaborator

Thanks @nickpoulos! And congrats on your first contribution! 🎉

@acrobat acrobat assigned acrobat and unassigned acrobat May 18, 2020
@nickpoulos

Copy link
Copy Markdown
Contributor Author

Thank you! Happy to be able to help for once!

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.

2 participants