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

Fix support for getting single files from GitHub (v2) #356

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from

Conversation

arikkfir
Copy link

@arikkfir arikkfir commented Apr 11, 2022

This currently fails for GitHub (and possibly other Git repositories) because there is an assumption in the client.go file that the subDir segment is always a directory.

However, for the URL "https://github.com/owner/repo/subdir/file.txt[](https://github.com/arikkfir)" the "subDir" variable would actually be a file (subdir/file.txt) and hence the client should use copyFile rather than copyDir when copying the subDir to the final destination.

This change fixes that to check whether the "subDir" variable is a file or a directory, and appropriately uses copyDir or copyFile. It also returns the single file in the "GetResult" object, if indeed a single file was requested.

Tests attached.

This fixes #98

@arikkfir arikkfir changed the title Fix GetFile support for GitHub getter Fix GetFile support for GitHub getter (v2) Apr 13, 2022
@arikkfir arikkfir force-pushed the support_getfile_from_github_v2 branch from e03eae6 to e7578c2 Compare April 14, 2022 20:33
@arikkfir arikkfir changed the title Fix GetFile support for GitHub getter (v2) Fix support for getting single files from GitHub (v2) Apr 14, 2022
@arikkfir arikkfir force-pushed the support_getfile_from_github_v2 branch 2 times, most recently from e7578c2 to 635e41d Compare August 3, 2022 15:14
@arikkfir
Copy link
Author

arikkfir commented Aug 3, 2022

Rebased branch to include new commits since April 2022 - and the change is still relevant and needed.

This currently fails for GitHub (and possibly other Git repositories)
because there is an assumption in the "client.go" file that the "subDir"
segment is always a directory.

However, for this URL:

https://github.com/owner/repo/subdir/file.txt

The "subDir" variable would actually be a file ("subdir/file.txt") and
hence the client should use "copyFile" rather than "copyDir" when
copying the "subDir" to the final destination.

This change fixes that to check whether the "subDir" variable is a file
or a directory, and appropriately uses "copyDir" or "copyFile". It also
returns the single file in the "GetResult" object, if indeed a single
file was requested.

Tests attached.
@arikkfir arikkfir force-pushed the support_getfile_from_github_v2 branch from 635e41d to 66abd65 Compare August 3, 2022 16:06
@arikkfir
Copy link
Author

arikkfir commented Aug 3, 2022

Rebased this branch off of the v2.1.0 tag, so that it can be fully compatible with the v2.1.0 release (with the addition of this fix).

@JuryA
Copy link

JuryA commented Oct 31, 2022

Any news? Still facing this issue... :/

@nywilken nywilken self-requested a review February 13, 2023 17:22
@nywilken nywilken self-assigned this Feb 13, 2023
@nywilken
Copy link
Contributor

nywilken commented Feb 13, 2023

@arikkfir sorry for not being able to get to this sooner. Thank you for the contribution.

I've assigned the change to myself for review.

@rucciva
Copy link

rucciva commented Jul 5, 2024

hello, is there any update to this, thanks

@nywilken nywilken removed their request for review September 13, 2024 18:03
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.

4 participants