简体   繁体   English

GitHub从raw.githubusercontent获取存储库中所有文件的列表?

[英]GitHub get a list of all files in a repository from raw.githubusercontent?

I'm building a program that I would like to be able to update from git. 我正在构建一个我希望能够从git更新的程序。 I can compare the files to raw.githubusercontent.com and, if they are different, pull them. 我可以将这些文件与raw.githubusercontent.com进行比较,如果它们不同,则将它们拉出。 However, if a file is added to the repository instead of just changed, the program won't know to check that url. 但是,如果将文件添加到存储库而不是仅更改文件,则程序将不会检查该URL。 Is there a way to get a list of all files in a repository from GitHub to check? 有没有办法从GitHub获取存储库中所有文件的列表以进行检查?

By the way, I am not using the GitHub API because I do not wish to include my API token in the distributed program, or force the users to have their own GitHub account. 顺便说一句,我不使用GitHub API,因为我不想在分布式程序中包含我的API令牌,也不希望用户拥有自己的GitHub帐户。 If there is a way to download a repo from git without including a token, I would accept that as a solution as well. 如果有一种方法可以从git下载仓库而不包含令牌,那么我也可以接受它作为解决方案。

Git provide git-ls-remote , but you cannot use that feature to get directory listing. Git提供了git-ls-remote ,但是您不能使用该功能来获取目录列表。 So, the only way to get a listing is using Github API or web interface. 因此,获得列表的唯一方法是使用Github API或Web界面。 And you don't need any API tokens to get a content of a public repository: 而且,您不需要任何API令牌即可获取公共存储库的内容:

$ curl https://api.github.com/repos/lassana/continuous-audiorecorder/contents/
[
  {
    "name": ".gitignore",
    "path": ".gitignore",
    "sha": "7f6dd1b098cedd0b87abcdf09e5d638d49dbd312",
    "size": 338,
    "url": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/.gitignore?ref=master",
    "html_url": "https://github.com/lassana/continuous-audiorecorder/blob/master/.gitignore",
    "git_url": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/blobs/7f6dd1b098cedd0b87abcdf09e5d638d49dbd312",
    "download_url": "https://raw.githubusercontent.com/lassana/continuous-audiorecorder/master/.gitignore",
    "type": "file",
    "_links": {
      "self": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/.gitignore?ref=master",
      "git": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/blobs/7f6dd1b098cedd0b87abcdf09e5d638d49dbd312",
      "html": "https://github.com/lassana/continuous-audiorecorder/blob/master/.gitignore"
    }
  },
  {
    "name": "LICENSE",
    "path": "LICENSE",
    "sha": "9be97c167682f638144ea1fe1b3d756394a91c37",
    "size": 1304,
    "url": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/LICENSE?ref=master",
    "html_url": "https://github.com/lassana/continuous-audiorecorder/blob/master/LICENSE",
    "git_url": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/blobs/9be97c167682f638144ea1fe1b3d756394a91c37",
    "download_url": "https://raw.githubusercontent.com/lassana/continuous-audiorecorder/master/LICENSE",
    "type": "file",
    "_links": {
      "self": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/LICENSE?ref=master",
      "git": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/blobs/9be97c167682f638144ea1fe1b3d756394a91c37",
      "html": "https://github.com/lassana/continuous-audiorecorder/blob/master/LICENSE"
    }
  },
  {
    "name": "README.md",
    "path": "README.md",
    "sha": "2b8fd57a2ec70af5fbfcf3c1377217e3f99b880c",
    "size": 2108,
    "url": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/README.md?ref=master",
    "html_url": "https://github.com/lassana/continuous-audiorecorder/blob/master/README.md",
    "git_url": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/blobs/2b8fd57a2ec70af5fbfcf3c1377217e3f99b880c",
    "download_url": "https://raw.githubusercontent.com/lassana/continuous-audiorecorder/master/README.md",
    "type": "file",
    "_links": {
      "self": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/README.md?ref=master",
      "git": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/blobs/2b8fd57a2ec70af5fbfcf3c1377217e3f99b880c",
      "html": "https://github.com/lassana/continuous-audiorecorder/blob/master/README.md"
    }
  },
  {
    "name": "build.gradle",
    "path": "build.gradle",
    "sha": "f7a7ae7e2e8d616549aa5f3dcb92fb6986d58420",
    "size": 99,
    "url": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/build.gradle?ref=master",
    "html_url": "https://github.com/lassana/continuous-audiorecorder/blob/master/build.gradle",
    "git_url": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/blobs/f7a7ae7e2e8d616549aa5f3dcb92fb6986d58420",
    "download_url": "https://raw.githubusercontent.com/lassana/continuous-audiorecorder/master/build.gradle",
    "type": "file",
    "_links": {
      "self": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/build.gradle?ref=master",
      "git": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/blobs/f7a7ae7e2e8d616549aa5f3dcb92fb6986d58420",
      "html": "https://github.com/lassana/continuous-audiorecorder/blob/master/build.gradle"
    }
  },
  {
    "name": "drone-io.sh",
    "path": "drone-io.sh",
    "sha": "171868e680890535aa3006dafa885f36a1ba4c8b",
    "size": 660,
    "url": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/drone-io.sh?ref=master",
    "html_url": "https://github.com/lassana/continuous-audiorecorder/blob/master/drone-io.sh",
    "git_url": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/blobs/171868e680890535aa3006dafa885f36a1ba4c8b",
    "download_url": "https://raw.githubusercontent.com/lassana/continuous-audiorecorder/master/drone-io.sh",
    "type": "file",
    "_links": {
      "self": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/drone-io.sh?ref=master",
      "git": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/blobs/171868e680890535aa3006dafa885f36a1ba4c8b",
      "html": "https://github.com/lassana/continuous-audiorecorder/blob/master/drone-io.sh"
    }
  },
  {
    "name": "gradle",
    "path": "gradle",
    "sha": "f41799c99d13e934de8e71fc039ee5982ed89875",
    "size": 0,
    "url": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/gradle?ref=master",
    "html_url": "https://github.com/lassana/continuous-audiorecorder/tree/master/gradle",
    "git_url": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/trees/f41799c99d13e934de8e71fc039ee5982ed89875",
    "download_url": null,
    "type": "dir",
    "_links": {
      "self": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/gradle?ref=master",
      "git": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/trees/f41799c99d13e934de8e71fc039ee5982ed89875",
      "html": "https://github.com/lassana/continuous-audiorecorder/tree/master/gradle"
    }
  },
  {
    "name": "gradlew",
    "path": "gradlew",
    "sha": "91a7e269e19dfc62e27137a0b57ef3e430cee4fd",
    "size": 5080,
    "url": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/gradlew?ref=master",
    "html_url": "https://github.com/lassana/continuous-audiorecorder/blob/master/gradlew",
    "git_url": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/blobs/91a7e269e19dfc62e27137a0b57ef3e430cee4fd",
    "download_url": "https://raw.githubusercontent.com/lassana/continuous-audiorecorder/master/gradlew",
    "type": "file",
    "_links": {
      "self": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/gradlew?ref=master",
      "git": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/blobs/91a7e269e19dfc62e27137a0b57ef3e430cee4fd",
      "html": "https://github.com/lassana/continuous-audiorecorder/blob/master/gradlew"
    }
  },
  {
    "name": "gradlew.bat",
    "path": "gradlew.bat",
    "sha": "8a0b282aa6885fb573c106b3551f7275c5f17e8e",
    "size": 2314,
    "url": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/gradlew.bat?ref=master",
    "html_url": "https://github.com/lassana/continuous-audiorecorder/blob/master/gradlew.bat",
    "git_url": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/blobs/8a0b282aa6885fb573c106b3551f7275c5f17e8e",
    "download_url": "https://raw.githubusercontent.com/lassana/continuous-audiorecorder/master/gradlew.bat",
    "type": "file",
    "_links": {
      "self": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/gradlew.bat?ref=master",
      "git": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/blobs/8a0b282aa6885fb573c106b3551f7275c5f17e8e",
      "html": "https://github.com/lassana/continuous-audiorecorder/blob/master/gradlew.bat"
    }
  },
  {
    "name": "recorder",
    "path": "recorder",
    "sha": "6ef2ce50d4304ab2e5a069d494a3061ea49b08fc",
    "size": 0,
    "url": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/recorder?ref=master",
    "html_url": "https://github.com/lassana/continuous-audiorecorder/tree/master/recorder",
    "git_url": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/trees/6ef2ce50d4304ab2e5a069d494a3061ea49b08fc",
    "download_url": null,
    "type": "dir",
    "_links": {
      "self": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/recorder?ref=master",
      "git": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/trees/6ef2ce50d4304ab2e5a069d494a3061ea49b08fc",
      "html": "https://github.com/lassana/continuous-audiorecorder/tree/master/recorder"
    }
  },
  {
    "name": "sample",
    "path": "sample",
    "sha": "dd4460e7d22d1b4d5e659315e8bedd3de240dc3b",
    "size": 0,
    "url": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/sample?ref=master",
    "html_url": "https://github.com/lassana/continuous-audiorecorder/tree/master/sample",
    "git_url": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/trees/dd4460e7d22d1b4d5e659315e8bedd3de240dc3b",
    "download_url": null,
    "type": "dir",
    "_links": {
      "self": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/sample?ref=master",
      "git": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/trees/dd4460e7d22d1b4d5e659315e8bedd3de240dc3b",
      "html": "https://github.com/lassana/continuous-audiorecorder/tree/master/sample"
    }
  },
  {
    "name": "settings.gradle",
    "path": "settings.gradle",
    "sha": "1a32e417c62b4ae544744249dcb4fecfa7b95fc8",
    "size": 30,
    "url": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/settings.gradle?ref=master",
    "html_url": "https://github.com/lassana/continuous-audiorecorder/blob/master/settings.gradle",
    "git_url": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/blobs/1a32e417c62b4ae544744249dcb4fecfa7b95fc8",
    "download_url": "https://raw.githubusercontent.com/lassana/continuous-audiorecorder/master/settings.gradle",
    "type": "file",
    "_links": {
      "self": "https://api.github.com/repos/lassana/continuous-audiorecorder/contents/settings.gradle?ref=master",
      "git": "https://api.github.com/repos/lassana/continuous-audiorecorder/git/blobs/1a32e417c62b4ae544744249dcb4fecfa7b95fc8",
      "html": "https://github.com/lassana/continuous-audiorecorder/blob/master/settings.gradle"
    }
  }
]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有没有办法获取 GitHub 存储库中所有版本的列表? - Is there a way to get a list of all the releases in a GitHub repository? Python 获取公共 GitHub 存储库中的 csv 文件列表 - Python get list of csv files in public GitHub repository 用于Python的Github API:PyGithub - 获取特定存储库的所有提交的列表 - Github API for Python : PyGithub - get a list of all commits for a particular repository 如何从 github 存储库中获取分支列表? - How do i get a list of branches from a github repository? 如何读取Github存储库中的所有文本文件? - How to read all text files in Github repository? 从私有存储库获取原始数据 - Get raw data from private repository 合并来自 Github Repository Link 的所有 csv 文件并使其成为一个 csv 文件 - Combining all csv files from Github Repository Link and make it a one csv file 从提交中获取 GitHub 存储库 URL - Get GitHub repository URL from commit 如何列出我的存储库中的所有文件夹和文件 - How to list all folder and files in my repository Github API 如何使用 python 语言获取具有特定扩展名(.c、.cpp、.py 等)的 git 存储库的所有文件的计数? - Github API How to get a count of all the files of a git repository with a particular extension (.c, .cpp, .py etc) using python language?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM