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

Oktokit zipball download not including .git file in zip #502

Open
SohelKabir opened this issue Aug 9, 2022 · 5 comments
Open

Oktokit zipball download not including .git file in zip #502

SohelKabir opened this issue Aug 9, 2022 · 5 comments
Labels
Type: Bug Something isn't working as documented
Projects

Comments

@SohelKabir
Copy link

SohelKabir commented Aug 9, 2022

I tried to download github repository zip file with oktokit/core like this but not getting .git file in folder when extract the files!

const response = await octokit.request('GET /repos/${repoFullName}/zipball', {
    owner: owner,
    repo: repoName,
    ref: 'main',
  })

Is this expected behavior or bug?

"@octokit/core": "^4.0.4",

@SohelKabir SohelKabir added the Type: Bug Something isn't working as documented label Aug 9, 2022
@ghost ghost added this to Bugs in JS Aug 9, 2022
@timrogers
Copy link

👋🏻 Thanks for reaching out! This API just gives you the repository contents for a particular ref (e.g. branch, tag or commit), and doesn't include the whole Git history (etc.) in the .git directory. If you want to have all of that, your best bet is to clone the repo with Git itself.

Out of interest, why do you want the .git directory?

@SohelKabir
Copy link
Author

@timrogers thanks for reply. We are developing a platform where you can import code from github so we need a copy of the whole repo in user's virtual machine. In that case user need git info to commit and update the repo with github after some modification. Is there any other way to download whole repo other than using git clone command ?

@timrogers
Copy link

There isn't, as far as I know, any way to download a repo from the API including all of the history in the .git.

You should be able to clone with Git using an API access token, e.g. git clone your-token-goes-here@github.com/octokit/octokit.rb.git. Would that work for you?

@SohelKabir
Copy link
Author

Since this clone command happens within the code in node.js I have to spawn a shell to execute git clone command which we trying to avoid. I know git clone command works but it's slower than downloading whole repo.

@nickfloyd
Copy link
Contributor

Hey @SohelKabir, You might need to try the artifact endpoint as the download an archive endpoint will only create an archive, much like it does with the release, at a given :ref and will contain no actual history.

Though I have not implemented it myself, I have a suggestion that might work. There are a few gymnastics involved with using this ( the idea is based on the result of an action).

A possible workflow for this would be:

  1. For the given repo you have an action that generates an archive of the git command git clone
  2. In your app you list the artifacts for the name of the action
  3. You then make an HTTP request using the value from the archive_download_url field in the response body.

Note this requires the actions scope on whatever auth token you have to be able to download the archive.

We typically do not have APIs that reproduce the behavior of git. This is because our APIs are trying to extend our platform, not git itself. I hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented
Projects
No open projects
JS
  
Bugs
Development

No branches or pull requests

3 participants