我按照这个文档从bitbucket获取一个令牌值和一个令牌秘密:https://confluence.atlassian.com/display/BITBUCKET/OAuth+on+Bitbucket
之后,我想通过使用该令牌来推/拉到给定的仓库.
在Github,我可以像这样使用令牌:https: //help.github.com/articles/git-automation-with-oauth-tokens#step-2-clone-a-repository
我的问题是如何在bitbucket(mercurial/git)上使用这种http授权?
我想编写一个应用程序来生成 SSH 2 RSA 公钥和私钥。
我想获得 PuTTY 密钥生成器可以生成的格式的密钥。

在 ChilKat 的帮助下,我也可以生成公钥和私钥,但我不知道如何获得这种格式。
是否有任何示例可以获取该格式的密钥,或者我错过了什么?
非常感谢!
我创建了一个 ASP.NET MVC 应用程序,它可以在 Bitbucket 上授权用户。我使用CSharp.Bitbucket 库来获取令牌秘密和令牌值。
该OAuth的教程说,与令牌,我可以进行API调用。
我知道我可以像这样使用基本授权调用 API:
string url = "https://bitbucket.org/api/1.0/user/";
var request = WebRequest.Create(url) as HttpWebRequest;
string credentials = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes("username" + ":" + "password"));
request.Headers.Add("Authorization", "Basic " + credentials);
using (var response = request.GetResponse() as HttpWebResponse)
{
var reader = new StreamReader(response.GetResponseStream());
string json = reader.ReadToEnd();
}
Run Code Online (Sandbox Code Playgroud)
但是如何使用访问令牌调用 API?
非常感谢!
我想删除使用LibGit2Sharp从远程存储库克隆的本地repo文件夹.我在这里读到,我必须在删除它之前Dispose()存储库,但它仍然无法正常工作.
using (var repo = new LibGit2Sharp.Repository(path))
{
repo.Dispose();
}
Directory.DeleteFolder(path);
Run Code Online (Sandbox Code Playgroud)
我还有一个例外:
Access to the path 'c16566a7-202a-4c8a-84de-3e3caadd5af9' is denied.
Run Code Online (Sandbox Code Playgroud)
'path'变量的内容如下:
C:\Users\USERNAME\AppData\Local\dftmp\Resources\c16566a7-202a-4c8a-84de-3e3caadd5af9\directory\UserRepos\github.com\domonkosgabor\testrepo
Run Code Online (Sandbox Code Playgroud)
此文件夹由辅助角色创建到本地存储.
我该怎么做才能删除整个文件夹(包括.git)?
我想使用 LibGit2Sharp 将给定分支克隆到本地存储库。
var repoPath = LibGit2Sharp.Repository.Clone("https://something", localpath, cloneOptions);
using (var repo = new LibGit2Sharp.Repository(repoPath))
{
var branches = repo.Branches.GetEnumerator();
}
Run Code Online (Sandbox Code Playgroud)
使用 repo.Branches.GetEnumerator() 我可以看到每个远程分支,但是使用 Clone 命令我只能从 GitHub 克隆 master 分支?我如何克隆“testBranch”或其他东西?
实际上,默认情况下,Clone()它负责在本地检索所有分支的所有提交。默认情况下,只有远程 HEAD 分支(通常origin/master)会获取自动创建的本地分支副本,然后将其检出。
因此,一旦执行克隆,您所要做的就是从您想要执行此操作的远程分支创建一个本地分支,并检查这个新创建的分支。
例如,假设您对分支感兴趣my-feature-branch并且您的远程名称为origin:
Branch remoteBranch = repo.Branches["origin/my-feature-branch"];
Branch newLocalBranch = repo.CreateBranch("my-feature-branch");
// Make the local branch track the upstream one
repo.Branches.Update(newLocalBranch ,
b => b.TrackedBranch = remoteBranch.CanonicalName);
Branch trackingBranch = repo.Branches["my-feature-branch"];
repo.Checkout(trackingBranch);
Run Code Online (Sandbox Code Playgroud)
FWIW,有一个待处理的拉取请求,允许用户明确指定希望查看签出的分支。
编辑
我根据您的建议更新了我的代码,但它仍然无法正常工作。我的本地存储库的内容与trackingBranch不相等,它仍然代表master分支的内容。
var remoteBranch = …Run Code Online (Sandbox Code Playgroud) 我通过以下方式使用LibGit2Sharp.Credentials类一段时间:
LibGit2Sharp.Credentials credentials = new UsernamePasswordCredentials()
{
Username = TokenValue,
Password = ""
};
var pushOptions = new PushOptions() { Credentials = credentials} ;
Run Code Online (Sandbox Code Playgroud)
现在LibGit2Sharp.PushOptions.Credentials是绝对的,我必须使用CredentialsProvider.
我想问你CredentialsProvider在这种情况下使用的正确方法是什么?
非常感谢你!
我想创建自己的具有全球知名度的服务。为了实现这一点,我遵循了这个示例解决方案。
一切顺利,我可以在一个类中调用我的服务,该类扩展自 Package 抽象类,如下所示:
public class ClientPackage : Package
{
private void GetGlobalServiceCallback(object sender, EventArgs args)
{
IMyGlobalService service = GetService(typeof(SMyGlobalService)) as IMyGlobalService;
}
}
Run Code Online (Sandbox Code Playgroud)
因为我在一个包中,所以我可以轻松调用 GetService 并且可以获得我的服务。但是,如果我想从一个不扩展 Package 抽象类的类获取服务,该怎么办?
例如,我有一个类,它实现了 ITagger 接口。如果我想获取此类中的服务,我必须以这种方式使用 Package.GetGlobalService() 方法:
var txtMgr = (IVsTextManager)Package.GetGlobalService(typeof(SVsTextManager));
Run Code Online (Sandbox Code Playgroud)
我尝试使用 Package.GetGlobalServie() 获取自己的服务,但总是得到 null。链接的示例代码不包含我的问题的解决方案。
我可能错过了什么或者我在获得服务时遇到了错误的情况吗?
编辑:
好吧,假设我必须使用 MEF 来获取我的服务,因为我无法使用 Package.GetGlobalService() 获取我的服务。
我有一个包含 2 个项目的解决方案。一种是类库,其中包含这样的接口:
public interface INamesAccessor
{
IEnumerable<string> GetNames();
}
Run Code Online (Sandbox Code Playgroud)
另一个项目是 VSPackage(与第一个项目有参考),它也实现了我的接口:
[Export(typeof(INamesAccessor))]
public sealed class BitbucketExtensionPackage : Package, INamesAccessor
{
private IEnumerable<string> _names { get; set; } …Run Code Online (Sandbox Code Playgroud)