小说:手赚平台大全作者:杜陵密更新时间:2019-02-22字数:70807
喉咙上下动了几下,可惜无法出声,林风身子贴近,“谷主,欲望泉到底是什么?”
看得韩非和海子他们朝工事这边冲来,楼上的鬼子军官不断喊叫着,大批鬼子宪兵和鬼子步兵冲大楼各处跑出来,但还没等他们看见韩非他们,就有几个鬼子军官的脑袋被打碎,脑浆和着血一股脑儿的流出来,尸体四仰八叉的躺在大楼前面的空地上。
怎么办?李亨的眉头皱成一团,陈玄礼的兵权必须及早削除,不能再让他出任关中军主帅,必须找一个自己绝对信得过的人,那这个人谁最合适呢?
叶扬淡淡的说道:“想必应该是训练营里出了什么事了,不用担心,静观其变。既然没有直接对我们下手,那就说明我们的安全还是没有问题的,他们应该是有别的要求。”
ASP.NET Core 2.0 开源Git HTTP Server,实现类似 GitHub、GitLab。
GitHub:https://github.com/linezero/GitServer
设置
"GitSettings": {
"BasePath": "D:\Git",
"GitPath": "git"
}
需要先安装Git,并确保git 命令可以执行,GitPath 可以是 git 的绝对路径。
目前实现的功能
更多功能可以查看readme,也欢迎大家贡献支持。
LibGit2Sharp 用于操作Git库,实现创建读取仓库信息及删除仓库。
以下是主要代码:
public Repository CreateRepository(string name) { string path = Path.Combine(Settings.BasePath, name); Repository repo = new Repository(Repository.Init(path, true)); return repo; } public Repository CreateRepository(string name, string remoteUrl) { var path = Path.Combine(Settings.BasePath, name); try { using (var repo = new Repository(Repository.Init(path, true))) { repo.Config.Set("core.logallrefupdates", true); repo.Network.Remotes.Add("origin", remoteUrl, "+refs/*:refs/*"); var logMessage = ""; foreach (var remote in repo.Network.Remotes) { IEnumerable<string> refSpecs = remote.FetchRefSpecs.Select(x => x.Specification); Commands.Fetch(repo, remote.Name, refSpecs, null, logMessage); } return repo; } } catch { try { Directory.Delete(path, true); } catch { } return null; } } public void DeleteRepository(string name) { Exception e = null; for(int i = 0; i < 3; i++) { try { string path = Path.Combine(Settings.BasePath, name); Directory.Delete(path, true); } catch(Exception ex) { e = ex; } } if (e != null) throw new GitException("Failed to delete repository", e); }
执行Git命令
git-upload-pack
git-receive-pack
主要代码 GitCommandResult 实现IActionResult
public async Task ExecuteResultAsync(ActionContext context) { HttpResponse response = context.HttpContext.Response; Stream responseStream = GetOutputStream(context.HttpContext); string contentType = $"application/x-{Options.Service}"; if (Options.AdvertiseRefs) contentType += "-advertisement"; response.ContentType = contentType; response.Headers.Add("Expires", "Fri, 01 Jan 1980 00:00:00 GMT"); response.Headers.Add("Pragma", "no-cache"); response.Headers.Add("Cache-Control", "no-cache, max-age=0, must-revalidate"); ProcessStartInfo info = new ProcessStartInfo(_gitPath, Options.ToString()) { UseShellExecute = false, CreateNoWindow = true, RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true }; using (Process process = Process.Start(info)) { GetInputStream(context.HttpContext).CopyTo(process.StandardInput.BaseStream); if (Options.EndStreamWithNull) process.StandardInput.Write("