- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 LibGit2Sharp 向应用程序添加一些 Git 操作。我添加了 Microsoft.Alm.Authentication
以帮助进行身份验证和凭据管理器访问。它非常适合检索已从命令行输入的凭据。
但是,还有什么方法可以连接到提示输入 Github、BitBucket 和 VSTS 的用户名和密码的凭据管理器的登录 UI。此 UI 从命令行自动弹出,但在使用 LibGit2Sharp 时不会触发。
我查看了 Github 上的 GitCredentialManager 项目,我可以看到提供 UI 的组件,但在尝试弄清楚如何显式地 Hook 这些组件之前,我是否遗漏了一些方法,这是作为Microsoft.Alm.Authentication
(或相关包)的一部分?或者任何人都可以指出有关如何最好地连接它的示例或指南吗?
最佳答案
我设法让您的解决方案通过一些小的修改工作。我在此处粘贴示例代码以使用 git 凭据进行推送。它使用已存储在计算机中的凭据工作,并在第一次使用 UI 时提示输入凭据。
到目前为止,我遇到的唯一问题是提示用户输入凭据并且他们输入了无效的用户名/密码。 Git 向控制台写入请求用户/密码,并且在您输入之前该过程不会完成。试图监控 StandardError/Output 但没有成功。我在 stderror 中收到了错误文本,但只是在手动填写之后。
public void PushLibGit2Sharp(string repositoryFolder, string branch)
{
using (var repo = new Repository(repositoryFolder))
{
var options = new PushOptions
{
CredentialsProvider = (url, usernameFromUrl, types) =>
{
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = "git.exe",
Arguments = "credential fill",
UseShellExecute = false,
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true
};
Process process = new Process
{
StartInfo = startInfo
};
process.Start();
// Write query to stdin.
// For stdin to work we need to send \n instead of WriteLine
// We need to send empty line at the end
var uri = new Uri(url);
process.StandardInput.NewLine = "\n";
process.StandardInput.WriteLine($"protocol={uri.Scheme}");
process.StandardInput.WriteLine($"host={uri.Host}");
process.StandardInput.WriteLine($"path={uri.AbsolutePath}");
process.StandardInput.WriteLine();
// Get user/pass from stdout
string username = null;
string password = null;
string line;
while ((line = process.StandardOutput.ReadLine()) != null)
{
string[] details = line.Split('=');
if (details[0] == "username")
{
username = details[1];
}
else if (details[0] == "password")
{
password = details[1];
}
}
return new UsernamePasswordCredentials()
{
Username = username,
Password = password
};
}
};
repo.Network.Push(repo.Branches[branch], options);
}
}
关于c# - LibGit2Sharp 和身份验证 UI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50010941/
我尝试安装 expo在我执行命令后exp start但我得到了: Something went wrong installing the "sharp" module Cannot find modu
我需要在 fsharp 中制作一个程序,将输入文本文件中所有出现的字符串“needle”替换为另一个字符串“replace”。这个问题的一个很好的解决方案已经发布在这里: F# - fileRepla
我对该库有很多麻烦(显然是因为我是新手)。我正在使用Microsoft Visual Studio 2015。 首先,我绝对不知道如何将这个库添加到我的项目中。我也没有找到任何对Google有帮助的信
我已经按照错误所说的做了。我删除了 sharp 然后 npm install --ignore-scripts=false --verbose 但它仍然不起作用。 我也试过: rimraf node_
是否可以在 GeneticSharp 中实现不等式约束(线性或非线性)? 最佳答案 您可以在适应度函数中实现它们,通过与正常适应度范围相比以惊人的惩罚来惩罚违反约束的染色体。 我已经解决了一些问题并且
我在放置要从 Microsoft 引入的 F# 语言的概念和可能性时遇到问题。 F# 仅用于声明函数吗?还是通过将 F# 与普通 C# 或 VB 代码混合在一起,将应用程序“完全”用 F# 编写? 最
我正在使用 WkHtmlToXSharp (QT webkit) 库构建一个 HTML 到 PDF 转换器,并且想知道是否有人知道如何向文档添加页眉和页脚?我在这里看到了一些有关此库的问题,但找不到有
声明一个将对列表转换为关系的函数。 type Relation = ('a * 'b list) list 基本上,转动这个: [(2,"c");(1,"a");(2,"b")] 进入此: [(2,[
这是我的代码,当我输入一个非常大的数字时,我得到堆栈溢出错误有人知道为什么吗?当我输入一个非常大的数字时,我得到了那个错误,我不确定是什么原因造成的,只有大数字才能正常工作..... // // me
我有一个非托管结构,我想编码为 c sharp,它看起来基本上是这样的: struct MyStruct{ /* ... some stuff ... */ int numChild
给定多个时间跨度,我怎样才能得到一个数组来给出一天的工作小时数。 工作时间从09:00开始到17:00结束 例子: 15-Nov-2017 16:00 - 17-Nov-2017 12:00 -> 应
当然,最新的 Restsharp 中的默认值应该能够序列化“日期时间”。 下面是我的请求构建 var request = new RestRequest(Method.POST); request.R
我试图在另一个静态方法中调用 Browser.NewPageAsync(),但是当我调用它时,调用它的方法就退出了。 partial class Program { s
我使用 websocket-sharp ( https://github.com/sta/websocket-sharp )(仅限服务器端)。 我可以将许多客户端应用程序连接到我的 websocket
通过 Visual Studio,您可以轻松地为事件(单击按钮等)创建方法。有没有办法为多个事件创建一个方法,比如在单击三个按钮之一或输入多个文本框之一时运行的方法? 最佳答案 一旦您创建了该方法,您
我们刚刚开始试用 gStreamer-Sharp,看看我们是否可以创建管道,以便为我们的 .NET 软件编写媒体播放器组件。我们在 Windows/.NET 上运行,而不是 Linux/Mono。 一
我正在尝试使用 menustrip,我有 helpToolStripMenuItem_Click 可能有人会帮助我关于如何放置文档的代码,即如果我单击帮助,一个新的窗口显示出现像我从 vlc 帮助按钮
我有一个站点 Index.html 并且有一个从数据库生成的类别菜单。菜单由 HTML anchor 组成,但 href 属性始终类似于“Index.html#cat=xyz”,因为每个类别的内容都是
有人知道在 gtk# 中是否有一个 richtextbox 等效项或任何复制功能的方法吗? 我可能不需要完整的 rtf 支持,如果无法完成完整的 rtf 解决方案,我可能可以显示彩色文本。 提前致谢。
通常,我在 using 语句内声明流,以确保在我使用完流后正确处理流,这样我就不会在 using block 之外错误地调用它。 这里有一些例子: MSDN using Statement Refer
我是一名优秀的程序员,十分优秀!