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

Support in Set-GitHubContent to upload binary files #336

Closed

Conversation

StanleyGoldman
Copy link

@StanleyGoldman StanleyGoldman commented Sep 7, 2021

Description

As mentioned in #335, this pull request adds functionality to upload binary content with Set-GitHubContent

Issues Fixed

References

Checklist

  • You actually ran the code that you just wrote, especially if you did just "one last quick change".
  • Comment-based help added/updated, including examples.
  • Static analysis is reporting back clean.
  • New/changed code adheres to our coding guidelines.
  • Formatters were created for any new types being added.
  • New/changed code continues to support the pipeline.
  • Changes to the manifest file follow the manifest guidance.
  • Unit tests were added/updated and are all passing. See testing guidelines. This includes making sure that all pipeline input variations have been covered.
  • Relevant usage examples have been added/updated in USAGE.md.
  • If desired, ensure your name is added to our Contributors list

@HowardWolosky HowardWolosky added api-contents Work to complete the API's defined here: https://developer.github.com/v3/repos/contents enhancement An issue or pull request introducing new functionality to the project. labels Sep 15, 2021
Copy link
Member

@HowardWolosky HowardWolosky left a comment

Choose a reason for hiding this comment

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

Welcome to the project @StanleyGoldman, and thanks for the idea and for the submission. You're off to a great start. I've provided some feedback for you to take a look at when you get a chance.

Thanks again.

GitHubContents.ps1 Outdated Show resolved Hide resolved
GitHubContents.ps1 Outdated Show resolved Hide resolved
GitHubContents.ps1 Outdated Show resolved Hide resolved
GitHubContents.ps1 Outdated Show resolved Hide resolved
GitHubContents.ps1 Outdated Show resolved Hide resolved
GitHubContents.ps1 Outdated Show resolved Hide resolved
@@ -322,7 +325,6 @@ filter Set-GitHubContent
[string] $CommitMessage,

[Parameter(
Mandatory,
Copy link
Member

Choose a reason for hiding this comment

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

This needs to remain mandatory in its own ParameterSet.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Member

Choose a reason for hiding this comment

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

I think there was a misunderstanding with how I phrased this. It does need to be in its own parameter set, but not at the exclusion of the other required information. For instance, in order to what repo we're changing the content of, we still need to have the information either in the Elements parameter set or the Uri parameter set.

Previously, Content was being used with either of those parameter sets. Now you are introducing ContentPath as an alternative to Content. That means we're now exploded from 2 possible parameter sets to 4:

  • Elements with Content (maybe named ElementsContent)
  • Elements with ContentPath(maybe namedElementsContentPath`)
  • Uri with Content (maybe named UriContent)
  • Uri with ContentPath (maybe named UriContentPath)

You should try running Get-Help -Name Set-GitHubContent and look at the Syntax section. That will show you the various parameter sets that PowerShell has understood from the authored code. If you look at that with what you've currently authored, you should see more clearly how your new Content parameter set excludes the key information that we need, as well as prevents Content and ContentPath from being used when the repo information is provided.

Copy link
Member

Choose a reason for hiding this comment

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

Take a look at Get-GitHubEvent. That's an example where we had to explode the number of ParameterSets in order to support both the Elements and Uri repo scenarios while still accurately separating out the different possible inputs for the method itself.

@@ -322,7 +325,6 @@ filter Set-GitHubContent
[string] $CommitMessage,

[Parameter(
Copy link
Member

Choose a reason for hiding this comment

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

We may also want to allow this to be ValueFromPipeline to enable the content to be piped directly into this method. That's certainly an optional change for this PR though.

Copy link
Author

Choose a reason for hiding this comment

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

Do you want to file an issue for this, or should I?

Copy link
Member

Choose a reason for hiding this comment

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

If you're not addressing this in this PR, then go ahead and open it up as a suggestion once this PR lands.

@ghost
Copy link

ghost commented Sep 24, 2021

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 14 days of this comment.

Copy link
Member

@HowardWolosky HowardWolosky left a comment

Choose a reason for hiding this comment

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

Hey @StanleyGoldman,

Thanks so much for these updates, and my sincerest apologies for such a long time to get back to you with a follow-up review. I completely missed when you pushed up fixes earlier.

The main feedback here is still around the ParameterSets. Take a look at my more detailed comment in the reactivated comment thread to see if that gives you the additional information that you need to get it fixed.

@@ -322,7 +325,6 @@ filter Set-GitHubContent
[string] $CommitMessage,

[Parameter(
Copy link
Member

Choose a reason for hiding this comment

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

If you're not addressing this in this PR, then go ahead and open it up as a suggestion once this PR lands.

@@ -322,7 +325,6 @@ filter Set-GitHubContent
[string] $CommitMessage,

[Parameter(
Mandatory,
Copy link
Member

Choose a reason for hiding this comment

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

I think there was a misunderstanding with how I phrased this. It does need to be in its own parameter set, but not at the exclusion of the other required information. For instance, in order to what repo we're changing the content of, we still need to have the information either in the Elements parameter set or the Uri parameter set.

Previously, Content was being used with either of those parameter sets. Now you are introducing ContentPath as an alternative to Content. That means we're now exploded from 2 possible parameter sets to 4:

  • Elements with Content (maybe named ElementsContent)
  • Elements with ContentPath(maybe namedElementsContentPath`)
  • Uri with Content (maybe named UriContent)
  • Uri with ContentPath (maybe named UriContentPath)

You should try running Get-Help -Name Set-GitHubContent and look at the Syntax section. That will show you the various parameter sets that PowerShell has understood from the authored code. If you look at that with what you've currently authored, you should see more clearly how your new Content parameter set excludes the key information that we need, as well as prevents Content and ContentPath from being used when the repo information is provided.

@@ -231,6 +231,9 @@ filter Set-GitHubContent
.PARAMETER Content
The new file content.

.PARAMETER ContentPath
The local path to file content.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The local path to file content.
The local path to a file whose content should replace what is currently stored remotely in the repo at the Path location.

@@ -322,7 +325,6 @@ filter Set-GitHubContent
[string] $CommitMessage,

[Parameter(
Mandatory,
Copy link
Member

Choose a reason for hiding this comment

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

Take a look at Get-GitHubEvent. That's an example where we had to explode the number of ParameterSets in order to support both the Elements and Uri repo scenarios while still accurately separating out the different possible inputs for the method itself.

@ghost
Copy link

ghost commented May 8, 2022

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 14 days of this comment.

@ghost ghost closed this May 29, 2022
@ghost ghost added the auto-closed-unmerged An unmerged pull request that has been auto-closed due to lack of activity. label May 29, 2022
@ghost
Copy link

ghost commented May 29, 2022

This pull request has been automatically closed due to a lack of activity from the author. We understand. Life happens and other things likely came up. We would still love to see your contribution get merged in. Now that it has been closed, a different community member may wish to pick up where you left off. If so, they should speak up by commenting below. If you're still interested in completing this yourself, just respond back and let us know.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-contents Work to complete the API's defined here: https://developer.github.com/v3/repos/contents auto-closed-unmerged An unmerged pull request that has been auto-closed due to lack of activity. enhancement An issue or pull request introducing new functionality to the project. needs-author-feedback status-no-recent-activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants