# repository **Repository Path**: oscstudio/repository ## Basic Information - **Project Name**: repository - **Description**: libgit2 封装 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2016-09-27 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Git 操作 无全局锁实现 ## 编译 ``` rake compile ``` ## 打包 ``` rake package ``` ## 安装 ``` gem install pkg/repo-no-gvl-0.24.1.gem --local ``` ## 使用 仓库路径,url,refspecs 数组 ```ruby require 'repo' Repo::Remote.fetch(repo_path, url, refspecs, "username", "password") ``` 如: ```ruby require 'repo' Repo::Remote.fetch( "test1.git", "https://github.com/libgit2/libgit2.git", ["+refs/heads/*:refs/heads/*", "+refs/tags/*:refs/tags/*"], "", "") ``` ## 说明 `git_remote_fetch` 执行时,是通过异步调用 `git_remote_stop` 设置标志位来终止 fetch 操作。这意味着,取消操只有等到检查标志位时才会真正生效。 已知存在的问题有: * libgit2 中,只有接收完一个数据包(pkt-line)才会检查标志位。意味着发出终止请求后,可能需要等待接收到完整的数据包(pkt-line)后才会终止。 * libgit2 中,select 操作的超时时间已经调整为 60 秒,在网络中断时可能需要等待 60 s 取消操作才会生效。 * 最坏情况为两种情况叠加,终止时间较长,尤其时网络慢的情况下。