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
Added listGists method #1490
base: main
Are you sure you want to change the base?
Added listGists method #1490
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add at least one test for your new method.
Codecov Report
@@ Coverage Diff @@
## main #1490 +/- ##
============================================
- Coverage 78.81% 78.75% -0.07%
Complexity 2114 2114
============================================
Files 202 202
Lines 6429 6434 +5
Branches 361 362 +1
============================================
Hits 5067 5067
- Misses 1152 1157 +5
Partials 210 210
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
The test will need to use an account that has Gists and files in the Gists in order to work. I wrote a test that authenticates with my own token and it works, but I don't know how to write the test so that it will always work regardless of who is running it. This test works, but it will only work when a valid token has been given to it. @Test
public void gistListWithFilesTest() throws Exception {
GitHub gh = new GitHubBuilder().withOAuthToken("<valid token>").build();
List<GHGist> ghGistList = gh.listGists();
assertThat(ghGistList, notNullValue());
for(GHGist ghGist : ghGistList) {
assertThat(ghGist.getFiles(), notNullValue());
for(GHGistFile gistFileContent : ghGist.getFiles().values()) {
boolean hasContent = gistFileContent.getContent().length() > 0;
assertThat(hasContent, is(true));
}
}
} |
You can record a snapshot of the tests and then add the However, I'm going o make another suggestion. Instead of adding a new method to get the list Gists with contents, I suggest you add a github-api/src/main/java/org/kohsuke/github/GHLicense.java Lines 196 to 199 in bcb71a3
That will allow people to get the file contents if needed while preserving the incremental loading. The test will also be simpler. You can add a step at the end of the existing test for listing Gists. |
Description
Currently, when pulling down a list of GHGist objects, using
The GHGist objects returned in the list do not contain the contents of the files within each Gist, and there is no other method from which to pull down all gists with complete files in a single list. The reason for this seems to be that the GitHub API URL path that is used to pull the list from, intentionally does not include the contents of the file. The API docs seem to indicate a conservative data yield for that particular path, requiring a developer to then use another URL path from which to pull the individual Gists, which would then include the contents of the file.
I added this method to the GitHub class, which I have tested and verified that the list it returns is a complete list of the user's GHGist objects, where each file within the Gists has all of the data associated with the file, including content.
Fixes #1325
The only issue that came from
mvn -D enable-ci clean install site
was a warning about inconsistent synchronization, but it didn't just flag my code, it flagged other code in the class as well. It also indicates that the code might be just fine and that it could be a false positive due to the nature of the test.The method is relatively simple, I cannot see where it would cause any issues. However, I'm willing to make whatever changes are necessary.
Before submitting a PR:
mvn -D enable-ci clean install site
locally. If this command doesn't succeed, your change will not pass CI.main
. You will create your PR from that branch.When creating a PR: