delight-im/git-scraper

通过HTTP从公开可访问的".git"文件夹中下载整个Git仓库

v1.0.0 2015-10-24 14:39 UTC

This package is auto-updated.

Last update: 2024-08-24 07:21:34 UTC


README

通过HTTP从公开可访问的.git文件夹中下载整个Git仓库

  • 在Web服务器上不需要目录索引或目录浏览
  • 在服务器上运行git update-server-info不是必须的

需求

  • PHP 5.5.0+

安装

  1. 通过Composer包含库 [?]

    $ composer require delight-im/git-scraper
    
  2. 包含Composer自动加载器

    require __DIR__ . '/vendor/autoload.php';

用法

$scraper = new \Delight\GitScraper\GitScraper('http://www.example.com/.git/');
$scraper->fetch();
// var_dump($scraper->getFiles());
$scraper->download('./');

术语

  • hash
    • 用于识别Git中的对象
    • 始终使用SHA-1算法
    • 长度为20字节,40个十六进制字符或160位
    • 确保文件完整性
  • object
    • 存储在.git/objects
    • 可以通过其唯一的hash访问
    • 具有一个小头,描述其内容的类型和长度
    • 使用zlib压缩
    • 可以通过运行命令git cat-file -p {hash}进行预览(略微修改后的版本)
  • commit对象
    • 指向单个tree对象(存储为40个十六进制字符)
    • 包含提交者的姓名和电子邮件地址以及提交时间
    • 包括有关作者的信息(可能不是提交者)与提交者数据类似
    • 包含提交信息或提交描述
    • 也指向父树,以便可以浏览历史记录
  • tree对象
    • 对应于文件系统中的目录
    • 包含指向其他对象的指针(存储为20字节)
    • 在此处列出tree对象(即子目录)和blob对象(即目录中的文件)
  • blob对象
    • 类似于文件系统中的文件
    • 只是文件的二进制表示

进一步阅读

贡献

欢迎所有贡献!如果您想贡献,请首先创建一个问题,以便讨论您的功能、问题或疑问。

免责声明

您可能只应将此库用于您自己的网站和仓库。

许可证

Copyright (c) delight.im <info@delight.im>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  https://apache.ac.cn/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.