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

add create repo with template support #897

Merged

Conversation

bonnie-young
Copy link
Contributor

@bonnie-young bonnie-young commented Jul 19, 2020

Signed-off-by: Yang Ting bonnie.young@maxwit.com

Description

  1. Add two method for GHOrganization class:
  • createRepositoryWithParametersIsTemplate
  • createRepositoryWithTemplate
  1. And the corresponding test class
  • testCreateRepositoryWithParametersIsTemplate
  • testCreateRepositoryWithTemplate

Before submitting a PR:

We love getting PRs, but we hate asking people for the same basic changes every time.

  • Push your changes to a branch other than master. Create your PR from that branch.
  • Add JavaDocs and other comments
  • Write tests that run and pass in CI. See CONTRIBUTING.md for details on how to capture snapshot data.
  • Run mvn clean compile locally. This may reformat your code, commit those changes.
  • Run mvn -D enable-ci clean install site locally. If this command doesn't succeed, your change will not pass CI.

When creating a PR:

  • Fill in the "Description" above.
  • Enable "Allow edits from maintainers".

Copy link
Member

@bitwiseman bitwiseman left a comment

Choose a reason for hiding this comment

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

@bonnie-young
Thanks for the PR. High quality and with tests. Awesome!

Because this is adding new functionality, I need to look at it a bit more. I also don't know enough about repository template API to land this just yet. I'll look at this in the next few days.

Copy link
Member

@bitwiseman bitwiseman left a comment

Choose a reason for hiding this comment

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

@bonnie-young
This is good but I'll like to see it look a little different. I've added some suggestions as examples but don't treat those as what it has to look like.

If you feel strongly opposed to anything I'm suggesting please say so and we can discuss. I value all view points in the continuing growth and improvement of this project.

Thanks for contributing.

@@ -20,6 +22,22 @@
this.builder.with("name", name);
}

GHCreateRepositoryBuilder(GitHub root, String apiUrlTail, String name, Boolean isTemplate) {
Copy link
Member

@bitwiseman bitwiseman Jul 30, 2020

Choose a reason for hiding this comment

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

@bonnie-young Could you tell me why we need two new constructors?

Could we add an templateRepository(boolean) method to the builder instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, you are right! sorry for my carelessness.

* @throws IOException
* if repsitory cannot be created
*/
public GHRepository createWithTemplate() throws IOException {
Copy link
Member

@bitwiseman bitwiseman Jul 30, 2020

Choose a reason for hiding this comment

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

Similar to my previous comment could we have a fromTemplateRepository(String templateOwner, String templateRepo) method? I think the create() method could have .withPreview(BAPTISE) set in general without any negative effect, but I could be wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to the official doc , I don't think we can add an fromTemplateRepository(String templateOwner, String templateRepo) to the builder, Because templateOwner and templateRepo are parts of the request url not parameters. anyway, I will try it out, and find the result.
"create() method could have .withPreview(BAPTISE) set in general without any negative effect" —— I will try it later also, thanks for your idea.

* the organization of repository to be created
* @return the gh create repository builder
*/
public GHCreateRepositoryBuilder createRepositoryWithTemplate(String templateRepo,
Copy link
Member

@bitwiseman bitwiseman Jul 30, 2020

Choose a reason for hiding this comment

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

Ah, I see. The create from template repository has almost none of the parameters of general repository creation.
Still I think that limitation is something that could be explained in the javadoc for fromTemplateRepository(String templateOwner, String templateRepo) and include a link to the GitHub docs.

What you've done is good: guiding users to the a non-failure path. However, in this case, I'd rather reduce the surface area and added code in this library.

Also add @Preview and @Deprecated annotations to the methods that call GitHub Preview APIs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

“Also add @Preview and @deprecated annotations to the methods that call GitHub Preview APIs.” —— I see. Thank you for reminding me. But I don't know why need to add the @deprecated annotation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

“Also add @Preview and @deprecated annotations to the methods that call GitHub Preview APIs.” —— I see. Thank you for reminding me. But I don't know why need to add the @deprecated annotation.

I found the answer from oracle official doc:
When to Deprecate
When you design an API, carefully consider whether it supersedes an old API. If it does, and you wish to encourage developers (users of the API) to migrate to the new API, then deprecate the old API. Valid reasons to deprecate an API include:

  • It is insecure, buggy, or highly inefficient (I got this point)
  • It is going away in a future release
  • It encourages bad coding practices

src/test/java/org/kohsuke/github/GHOrganizationTest.java Outdated Show resolved Hide resolved
src/test/java/org/kohsuke/github/GHOrganizationTest.java Outdated Show resolved Hide resolved
@bitwiseman
Copy link
Member

@bonnie-young
Do you think you'll have time to work on this in the next week or two?

@bonnie-young
Copy link
Contributor Author

@bonnie-young
Do you think you'll have time to work on this in the next week or two?

@bitwiseman
I appreciate your reply and careful suggestions a lot. Sorry for the late reply. I asked for leave to go home these days and helped my family deal with some things. Now I get back to work. I will revise PR according to your comments in these two days :)

@bitwiseman
Copy link
Member

bitwiseman commented Aug 6, 2020

@bonnie-young
Excellent, thanks much. I hope all is well with you and your family.

I plan to publish the next version soon, but we can wait a few days to get this last addition in.

@bonnie-young
Copy link
Contributor Author

@bonnie-young
Excellent, thanks much. I hope all is well with you and your family.

I plan to publish the next version soon, but we can wait a few days to get this last addition in.

@bitwiseman
Thanks a lot!
In these two days, I will finish the modification after work. If I can't finish it in time, please release the next version first, then I'll be done before the next iteration.

@bonnie-young bonnie-young force-pushed the add-create-repo-with-template-support branch 3 times, most recently from a2bc5c6 to 5e703be Compare August 10, 2020 03:48
@bonnie-young bonnie-young force-pushed the add-create-repo-with-template-support branch from a3181a0 to 6afd248 Compare August 12, 2020 13:51
Signed-off-by: Yang Ting <bonnie.young@maxwit.com>
@bonnie-young bonnie-young force-pushed the add-create-repo-with-template-support branch from 6afd248 to 11bc669 Compare August 12, 2020 14:08
@bitwiseman bitwiseman merged commit ff4324a into hub4j:master Aug 12, 2020
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