本文整理汇总了C#中Octokit.GitHubClient类的典型用法代码示例。如果您正苦于以下问题:C# GitHubClient类的具体用法?C# GitHubClient怎么用?C# GitHubClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GitHubClient类属于Octokit命名空间,在下文中一共展示了GitHubClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeployProject
public async Task<bool> DeployProject()
{
await LoadProjectSettings();
var credentials = new Credentials(settings.GetString(OAuthTokenKey));
var client = new GitHubClient(new ProductHeaderValue("Kerbal Space Program for Visual Studio"))
{
Credentials = credentials
};
var name = "";
var versionName = "";
await threadHandler.AsyncPump.RunAsync(async () =>
{
using (var readLock = await projectLockService.ReadLockAsync())
{
var msBuildProject = await readLock.GetProjectAsync(await project.GetSuggestedConfiguredProjectAsync());
name = msBuildProject.GetPropertyValue("Name");
versionName = msBuildProject.GetProperty(nameof(VersionNamePattern)).EvaluatedValue;
}
});
var tag = new NewTag
{
Message = $"Release {versionName} of {name}",
Tag = versionName,
Type = TaggedType.Commit,
Tagger = new Committer(settings.GetString(UsernameKey), "", DateTimeOffset.UtcNow)
};
return false;
}
示例2: CreatesANewPrivateRepository
public async Task CreatesANewPrivateRepository()
{
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
{
Credentials = Helper.Credentials
};
var repoName = Helper.MakeNameWithTimestamp("private-repo");
var createdRepository = await github.Repository.Create(new NewRepository
{
Name = repoName,
Private = true
});
try
{
Assert.True(createdRepository.Private);
var repository = await github.Repository.Get(Helper.UserName, repoName);
Assert.True(repository.Private);
}
finally
{
Helper.DeleteRepo(createdRepository);
}
}
示例3: when_updating_issue_then_can_assign_non_existent_label
public async Task when_updating_issue_then_can_assign_non_existent_label()
{
var label = Guid.NewGuid().ToString();
var github = new GitHubClient(
new ProductHeaderValue("kzu-client"), new InMemoryCredentialStore(credentials));
var update = new IssueUpdate
{
State = ItemState.Open,
};
update.AddLabel(label);
await github.Issue.Update("kzu", "sandbox", 56, update);
var issue = await github.Issue.Get("kzu", "sandbox", 56);
Assert.True(issue.Labels.Any(l => l.Name == label));
var labels = await github.Issue.Labels.GetForRepository("kzu", "sandbox");
foreach (var l in labels.Select(l => l.Name)) {
Guid g;
if (Guid.TryParse(l, out g))
await github.Issue.Labels.Delete("kzu", "sandbox", l);
}
}
示例4: page
public List<Developer> page(int page = 1, int size = 40)
{
var credentials = new Octokit.Credentials(ConfigurationManager.AppSettings["user_git"], ConfigurationManager.AppSettings["pass_git"]);
Octokit.Connection connection = new Connection(new ProductHeaderValue("DevStore"));
Octokit.ApiConnection apiConn = new ApiConnection(connection);
Octokit.SearchUsersRequest search = new SearchUsersRequest("a");
search.AccountType = AccountSearchType.User;
search.PerPage = size;
search.Page = page;
Octokit.UsersClient userCliente = new UsersClient(apiConn);
Octokit.SearchClient searchUserService = new SearchClient(apiConn);
SearchUsersResult usersResult = searchUserService.SearchUsers(search).Result;
Octokit.GitHubClient gitClient = new GitHubClient(connection);
Octokit.UsersClient userClient = new UsersClient(apiConn);
List<Developer> developers = (from userGit in usersResult.Items
select new Developer
{
User = userGit.Login,
UrlAvatar = userGit.AvatarUrl.ToString(),
TotalRepo = userGit.PublicRepos,
TotalFollowers = userGit.Followers,
Price = ((userGit.PublicRepos * pesoTotalRepository) + (userGit.Followers * pesoTotalFollowers)) / (pesoTotalRepository + pesoTotalFollowers)
}).ToList();
return developers;
}
示例5: GetMissingStars
private static async Task<IEnumerable<Repository>> GetMissingStars(GitHubClient client)
{
var currentUser = await client.User.Current();
var repos = (await client.Repository.GetAllForCurrent()).Where(a => !a.Private).ToList();
var stars = await client.Activity.Starring.GetAllForCurrent();
return repos.Where(a => !stars.Any(b => string.Equals(a.Owner.Name, b.Owner.Name, StringComparison.OrdinalIgnoreCase) && string.Equals(a.FullName, b.FullName, StringComparison.OrdinalIgnoreCase)));
}
示例6: Main
static void Main(string[] args)
{
if (args.Length == 0)
{
throw new Exception("Missing github API token argument");
}
var token = args[0];
github = new GitHubClient(new ProductHeaderValue("Jackett"));
github.Credentials = new Credentials(token);
localVersion = GetJackettVersion();
/*var latestReleaseVersion = LatestGithubRelease().Result;
if (localVersion <= latestReleaseVersion)
{
Console.WriteLine("Latest Github release is {0}, will not upload local version {1}", latestReleaseVersion, localVersion);
return;
}*/
Console.WriteLine("Zipping release build for Windows " + localVersion);
ZippingReleaseBuildWindows();
Console.WriteLine("Zipping release build for Mono " + localVersion);
ZippingReleaseBuildMono();
UploadRelease().Wait();
}
示例7: GitHubRepository
public GitHubRepository(string appName, string token)
{
_gitHubClient = new GitHubClient(new ProductHeaderValue(appName))
{
Credentials = new Credentials(token)
};
}
示例8: HandleLoadStarted
private async void HandleLoadStarted(object sender, EventArgs e)
{
if (webView.Request.Url.AbsoluteString.StartsWith("http://youhaveissues.azurewebsites.net"))
{
webView.StopLoading();
var parameters = webView.Request.Url.Query.Split('&');
Task<OauthToken> authTokenTask = null;
foreach (var param in parameters)
{
var parts = param.Split('=');
if (parts[0] == "code")
{
var code = parts[1];
authTokenTask = unauthenticatedClient.Oauth.CreateAccessToken(
new OauthTokenRequest(config.ClientID, config.ClientSecret, code));
break;
}
}
if (authTokenTask != null)
{
var token = await authTokenTask;
var client = new GitHubClient(new ProductHeaderValue("YouHaveIssues"));
client.Credentials = new Credentials(token.AccessToken);
DismissViewController(animated: true, completionHandler: null);
AccountAuthenticated(this, new GitHubClientEventArgs(client));
}
}
}
示例9: GitHubApi
/// <summary>
/// Constructs a class for talking to GitHub
/// </summary>
/// <param name="organization">The organization you are interested in</param>
/// <param name="repository">The repository within an organization</param>
public GitHubApi(string organization, string repository)
{
_organization = organization;
_repository = repository;
_github = new GitHubClient(new ProductHeaderValue("Alteridem.GetChangeset"));
_github.Credentials = new Credentials(Secrets.TOKEN);
}
示例10: when_processing_issue_with_declared_plus_label_then_applies_it_with_plus
public async Task when_processing_issue_with_declared_plus_label_then_applies_it_with_plus()
{
var github = new GitHubClient(new ProductHeaderValue("kzu-client"), new InMemoryCredentialStore(credentials));
var repository = await github.Repository.Get("kzu", "sandbox");
var user = await github.User.Current();
var issue = await github.Issue.Create(
"kzu", "sandbox", new NewIssue("Auto-labeling to +doc"));
var labeler = new OctoIssuerJob(github, new IOctoIssuer[] { new AutoLabel(github) });
await labeler.ProcessAsync(new Octokit.Events.IssuesEvent
{
Action = IssuesEvent.IssueAction.Opened,
Issue = issue,
Repository = repository,
Sender = user,
});
var updated = await github.Issue.Get("kzu", "sandbox", issue.Number);
Assert.Equal("Auto-labeling to", updated.Title);
Assert.True(updated.Labels.Any(l => l.Name == "+Doc"));
await github.Issue.Update("kzu", "sandbox", issue.Number, new IssueUpdate { State = ItemState.Closed });
}
示例11: CreateIssueTrackers
private static void CreateIssueTrackers(IRepository repository, GitReleaseNotesArguments arguments)
{
_issueTrackers = new Dictionary<IssueTracker, IIssueTracker>
{
{
IssueTracker.GitHub,
new GitHubIssueTracker(repository, () =>
{
var gitHubClient = new GitHubClient(new ProductHeaderValue("GitReleaseNotes"));
if (arguments.Token != null)
{
gitHubClient.Credentials = new Credentials(arguments.Token);
}
return gitHubClient;
}, new Log(), arguments)
},
{
IssueTracker.Jira,
new JiraIssueTracker(new JiraApi(), arguments)
},
{
IssueTracker.YouTrack,
new YouTrackIssueTracker(new YouTrackApi(), arguments)
}
};
}
示例12: Index
public async Task<ActionResult> Index(string idea, string description)
{
if (idea == "" || idea == null)
{
ViewBag.Message = "Enter an idea yo!";
ViewBag.ImgUrl = "homerSad.jpg";
return View();
}
try
{
var client = new GitHubClient(new ProductHeaderValue("Nommer-Idea-Lodger"));
client.Credentials = new Credentials(Environment.GetEnvironmentVariable("GithubKey"));
var newIdea = new NewIssue(idea) { Body = description };
newIdea.Labels.Add("idea");
await client.Issue.Create("NickBrooks", "Nommer-Roadmap", newIdea);
ViewBag.Message = "You're an ideas man!";
ViewBag.ImgUrl = "homerHappy.jpg";
}
catch (Exception ex)
{
ViewBag.ImgUrl = "homerSad.jpg";
ViewBag.Message = ex.ToString();
}
return View();
}
示例13: Sync
public async Task Sync()
{
var github = new GitHubClient(new ProductHeaderValue("Jackett"));
var releases = await github.Release.GetAll("zone117x", "Jackett");
if (releases.Count > 0)
{
using (var db = new LiteDatabase(GetDBPath()))
{
var releaseCollection = db.GetCollection<Release>("Releases");
releaseCollection.Drop();
releaseCollection.EnsureIndex(x => x.When);
foreach (var release in releases)
{
releaseCollection.Insert(new Release()
{
When = release.PublishedAt.Value.DateTime,
Description = release.Body,
Title = release.Name,
Url = release.HtmlUrl,
Version = release.TagName
});
}
}
}
}
示例14: Execute
public IEnumerable<IDocument> Execute(IReadOnlyList<IDocument> inputs, IExecutionContext context)
{
GitHubClient github = new GitHubClient(new ProductHeaderValue("Wyam"), _url ?? GitHubClient.GitHubApiUrl);
if (_credentials != null)
{
github.Credentials = _credentials;
}
return inputs.AsParallel().Select(input =>
{
ConcurrentDictionary<string, object> results = new ConcurrentDictionary<string, object>();
foreach (KeyValuePair<string, Func<IDocument, IExecutionContext, GitHubClient, object>> request in _requests.AsParallel())
{
Trace.Verbose("Submitting {0} GitHub request for {1}", request.Key, input.Source);
try
{
results[request.Key] = request.Value(input, context, github);
}
catch (Exception ex)
{
Trace.Warning("Exception while submitting {0} GitHub request for {1}: {2}", request.Key, input.Source, ex.ToString());
}
}
return context.GetDocument(input, results);
});
}
示例15: createGistAsync
private static async Task<string> createGistAsync(string snippet)
{
try
{
var token = Options.SavedOptions.Instance.TokenValue;
if (String.IsNullOrWhiteSpace(token))
{
StatusBar.ShowStatus("Please provide GitHub access token in Tools > Options > Gistify");
return String.Empty;
}
var credentials = new Octokit.Credentials(token);
var connection = new Connection(new ProductHeaderValue("Whatever"))
{
Credentials = credentials
};
var github = new GitHubClient(connection);
var newGist = new NewGist()
{
Description = "Generated by Code Connect's Gistify",
Public = false,
};
newGist.Files.Add("fragment.cs", snippet);
var gist = await github.Gist.Create(newGist).ConfigureAwait(false);
return gist.HtmlUrl;
}
catch (Exception)
{
StatusBar.ShowStatus("Gistify ran into a problem creating the gist.");
return String.Empty;
}
}