當前位置: 首頁>>代碼示例>>C#>>正文


C# Octokit.GitHubClient類代碼示例

本文整理匯總了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;
        }
開發者ID:jkoritzinsky,項目名稱:Kerbal-Space-Program-For-Visual-Studio,代碼行數:29,代碼來源:GitHubDeploy.cs

示例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);
            }
        }
開發者ID:ninadamondikar,項目名稱:octokit.net,代碼行數:25,代碼來源:RepositoriesClientTests.cs

示例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);
			}
		}
開發者ID:LeCantaloop,項目名稱:OctoHook,代碼行數:25,代碼來源:OctoTests.cs

示例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;
        }
開發者ID:milkidis,項目名稱:devstore,代碼行數:26,代碼來源:DeveloperService.cs

示例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)));
 }
開發者ID:TerribleDev,項目名稱:stars.tparnell.io,代碼行數:7,代碼來源:ManageController.cs

示例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();
        }
開發者ID:iheijoushin,項目名稱:Jackett,代碼行數:26,代碼來源:Program.cs

示例7: GitHubRepository

 public GitHubRepository(string appName, string token)
 {
     _gitHubClient = new GitHubClient(new ProductHeaderValue(appName))
     {
         Credentials = new Credentials(token)
     };
 }
開發者ID:KevMain,項目名稱:TwitterBot,代碼行數:7,代碼來源:GitHubRepository.cs

示例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));
                }
            }
        }
開發者ID:dpoeschl,項目名稱:YouHaveIssues,代碼行數:30,代碼來源:GitHubLoginViewController.cs

示例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);
 }
開發者ID:rprouse,項目名稱:GetChanges,代碼行數:12,代碼來源:GitHubApi.cs

示例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 });
        }
開發者ID:LeCantaloop,項目名稱:OctoHook,代碼行數:26,代碼來源:AutoLabelTests.cs

示例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)
                }
            };
        }
開發者ID:pvandervelde,項目名稱:GitReleaseNotes,代碼行數:27,代碼來源:Program.cs

示例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();
        }
開發者ID:NickBrooks,項目名稱:Github-Idea-Lodger,代碼行數:30,代碼來源:HomeController.cs

示例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
                        });
                    }
                }
            }
        }
開發者ID:iheijoushin,項目名稱:Jackett,代碼行數:27,代碼來源:DatabaseService.cs

示例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);
     });
 }
開發者ID:ryanrousseau,項目名稱:Wyam,代碼行數:25,代碼來源:GitHub.cs

示例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;
            }
        }
開發者ID:CodeConnect,項目名稱:gistify,代碼行數:32,代碼來源:GitHubIntegration.cs


注:本文中的Octokit.GitHubClient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。