-
Notifications
You must be signed in to change notification settings - Fork 736
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
initial feature add #1986
Draft
gitPushPuppets
wants to merge
4
commits into
hub4j:main
Choose a base branch
from
gitPushPuppets:feat/add-custom-properties
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
initial feature add #1986
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/org/kohsuke/github/GHRepositoryCustomProperty.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.kohsuke.github; | ||
|
||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
|
||
/** | ||
* A custom property set on a repository in GitHub. | ||
* | ||
* @author gitPushPuppets | ||
*/ | ||
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, | ||
justification = "JSON API") | ||
public class GHRepositoryCustomProperty { | ||
|
||
/** | ||
* Create default GHRepositoryCustomProperty instance | ||
*/ | ||
public GHRepositoryCustomProperty() { | ||
} | ||
|
||
private String property_name; | ||
private String value; | ||
|
||
/** | ||
* Gets property_name | ||
* | ||
* @return the property_name | ||
*/ | ||
public String getPropertyName() { | ||
return property_name; | ||
} | ||
|
||
/** | ||
* Gets property value | ||
* | ||
* @return the property value | ||
*/ | ||
public String getValue() { | ||
return value; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
.../org/kohsuke/github/GHRepositoryTest/wiremock/testGetCustomProperties/__files/1-user.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"login": "bitwiseman", | ||
"id": 1958953, | ||
"node_id": "MDQ6VXNlcjE5NTg5NTM=", | ||
"avatar_url": "https://avatars3.githubusercontent.com/u/1958953?v=4", | ||
"gravatar_id": "", | ||
"url": "https://api.github.com/users/bitwiseman", | ||
"html_url": "https://github.com/bitwiseman", | ||
"followers_url": "https://api.github.com/users/bitwiseman/followers", | ||
"following_url": "https://api.github.com/users/bitwiseman/following{/other_user}", | ||
"gists_url": "https://api.github.com/users/bitwiseman/gists{/gist_id}", | ||
"starred_url": "https://api.github.com/users/bitwiseman/starred{/owner}{/repo}", | ||
"subscriptions_url": "https://api.github.com/users/bitwiseman/subscriptions", | ||
"organizations_url": "https://api.github.com/users/bitwiseman/orgs", | ||
"repos_url": "https://api.github.com/users/bitwiseman/repos", | ||
"events_url": "https://api.github.com/users/bitwiseman/events{/privacy}", | ||
"received_events_url": "https://api.github.com/users/bitwiseman/received_events", | ||
"type": "User", | ||
"site_admin": false, | ||
"name": "Liam Newman", | ||
"company": "Cloudbees, Inc.", | ||
"blog": "", | ||
"location": "Seattle, WA, USA", | ||
"email": "[email protected]", | ||
"hireable": null, | ||
"bio": "https://twitter.com/bitwiseman", | ||
"public_repos": 181, | ||
"public_gists": 7, | ||
"followers": 147, | ||
"following": 9, | ||
"created_at": "2012-07-11T20:38:33Z", | ||
"updated_at": "2020-02-06T17:29:39Z", | ||
"private_gists": 8, | ||
"total_private_repos": 10, | ||
"owned_private_repos": 0, | ||
"disk_usage": 33697, | ||
"collaborators": 0, | ||
"two_factor_authentication": true, | ||
"plan": { | ||
"name": "free", | ||
"space": 976562499, | ||
"collaborators": 0, | ||
"private_repos": 10000 | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...thub/GHRepositoryTest/wiremock/testGetCustomProperties/__files/2-orgs_hub4j-test-org.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"login": "hub4j-test-org", | ||
"id": 7544739, | ||
"node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", | ||
"url": "https://api.github.com/orgs/hub4j-test-org", | ||
"repos_url": "https://api.github.com/orgs/hub4j-test-org/repos", | ||
"events_url": "https://api.github.com/orgs/hub4j-test-org/events", | ||
"hooks_url": "https://api.github.com/orgs/hub4j-test-org/hooks", | ||
"issues_url": "https://api.github.com/orgs/hub4j-test-org/issues", | ||
"members_url": "https://api.github.com/orgs/hub4j-test-org/members{/member}", | ||
"public_members_url": "https://api.github.com/orgs/hub4j-test-org/public_members{/member}", | ||
"avatar_url": "https://avatars3.githubusercontent.com/u/7544739?v=4", | ||
"description": null, | ||
"is_verified": false, | ||
"has_organization_projects": true, | ||
"has_repository_projects": true, | ||
"public_repos": 11, | ||
"public_gists": 0, | ||
"followers": 0, | ||
"following": 0, | ||
"html_url": "https://github.com/hub4j-test-org", | ||
"created_at": "2014-05-10T19:39:11Z", | ||
"updated_at": "2015-04-20T00:42:30Z", | ||
"type": "Organization", | ||
"total_private_repos": 0, | ||
"owned_private_repos": 0, | ||
"private_gists": 0, | ||
"disk_usage": 147, | ||
"collaborators": 0, | ||
"billing_email": "[email protected]", | ||
"default_repository_permission": "none", | ||
"members_can_create_repositories": false, | ||
"two_factor_requirement_enabled": false, | ||
"plan": { | ||
"name": "free", | ||
"space": 976562499, | ||
"private_repos": 0, | ||
"filled_seats": 12, | ||
"seats": 0 | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Thoughts: I'm not sure that
Set
helps you here. You might want to represent this asList
- getting all of themMap<String, String>
- the docs seem to indicate that you can't have multiple properties with the samename
value on a repository or organization. And the properties are just name/value pairs...Map<String,CustomProperty>
- This might be a good choice for future proofing, in case GitHub decides to make CustomProperty records more complex in future.For either of the
Map
options you need to check whetherkey
value uniqueness case-insensitive, case-sensitive but restricted to ASCII, or literary any Unicode/UTF-8 String.I mean this as a discussion. I'm fully open to changing my mind.
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.
I got my custom properties returned to me using this code base referenced in a console app.
I was discussing map options with a friend of mine but haven't been able to get it to work yet. I am not familiar with how this repo handles object mapping and kept running into null errors.
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.
We use Jackson.
Give an example of where you get null errors and we'll see if we can figure it out.