public ObservableReleasesClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.Release;
            _connection = client.Connection;
        }
 public IssuesClientTests()
 {
     _gitHubClient = Helper.GetAuthenticatedClient();
     var repoName = Helper.MakeNameWithTimestamp("public-repo");
     _issuesClient = _gitHubClient.Issue;
     _repository = _gitHubClient.Repository.Create(new NewRepository { Name = repoName }).Result;
 }
        public ObservableDeploymentStatusClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.Deployment.Status;
            _connection = client.Connection;
        }
        public ObservableIssueReactionsClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.Reaction.Issue;
            _connection = client.Connection;
        }
        public TheEditMethod()
        {
            _github = Helper.GetAuthenticatedClient();
            _releaseClient = _github.Repository.Release;

            _context = _github.CreateRepositoryContext("public-repo").Result;
        }
示例#6
0
        public ObservableNotificationsClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _connection = client.Connection;
            _notificationsClient = client.Notification;
        }
 public ObservableSshKeysClient(IGitHubClient client)
 {
     Ensure.ArgumentNotNull(client, "client");
     
     _client = client.SshKey;
     _connection = client.Connection;
 }
        /// <summary>
        /// Initializes a new GitHub Repo Collaborators API client.
        /// </summary>
        /// <param name="client">An IGitHubClient client.</param>
        public ObservableRepoCollaboratorsClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.Repository.Collaborator;
            _connection = client.Connection;
        }
示例#9
0
 public InstallController(IConfiguration configuration, IGitHubClient gitHubClient)
 {
     if (configuration == null) throw new ArgumentNullException("configuration");
     if (gitHubClient == null) throw new ArgumentNullException("gitHubClient");
     _configuration = configuration;
     _gitHubClient = gitHubClient;
 }
    public DeploymentsClientTests()
    {
        _gitHubClient = Helper.GetAuthenticatedClient();

        _deploymentsClient = _gitHubClient.Repository.Deployment;

        var newRepository = new NewRepository(Helper.MakeNameWithTimestamp("public-repo"))
        {
            AutoInit = true
        };

        _repository = _gitHubClient.Repository.Create(newRepository).Result;
        _repositoryOwner = _repository.Owner.Login;

        var blob = new NewBlob
        {
            Content = "Hello World!",
            Encoding = EncodingType.Utf8
        };

        var blobResult = _gitHubClient.GitDatabase.Blob.Create(_repositoryOwner, _repository.Name, blob).Result;

        var newTree = new NewTree();
        newTree.Tree.Add(new NewTreeItem
        {
            Type = TreeType.Blob,
            Mode = FileMode.File,
            Path = "README.md",
            Sha = blobResult.Sha
        });

        var treeResult = _gitHubClient.GitDatabase.Tree.Create(_repositoryOwner, _repository.Name, newTree).Result;
        var newCommit = new NewCommit("test-commit", treeResult.Sha);
        _commit = _gitHubClient.GitDatabase.Commit.Create(_repositoryOwner, _repository.Name, newCommit).Result;
    }
 public TheCreateReactionMethod()
 {
     _github = Helper.GetAuthenticatedClient();
     var repoName = Helper.MakeNameWithTimestamp("public-repo");
     _issuesClient = _github.Issue;
     _context = _github.CreateRepositoryContext(new NewRepository(repoName)).Result;
 }
        public ObservableCommitStatusClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.Repository.Status;
            _connection = client.Connection;
        }
        public ObservableRepositoryPagesClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.Repository.Page;
            _connection = client.Connection;
        }
        public ObservableGistsClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.Gist;
            Comment = new ObservableGistCommentsClient(client);
        }
        public ObservableStarredClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.Activity.Starring;
            _connection = client.Connection;
        }
        public ObservableRepositoryCommitsClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _connection = client.Connection;
            _commit = client.Repository.Commit;
        }
        public ObservableOrganizationsClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.Organization;
            _connection = client.Connection;
        }
        public ObservableIssueCommentsClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.Issue.Comment;
            _connection = client.Connection;
        }
    public AssigneesClientTests()
    {
        _github = Helper.GetAuthenticatedClient();
        var repoName = Helper.MakeNameWithTimestamp("public-repo");

        _context = _github.CreateRepositoryContext(new NewRepository(repoName)).Result;
    }
        public ObservableIssuesLabelsClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _connection = client.Connection;
            _client = client.Issue.Labels;
        }
        public ObservableMilestonesClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.Issue.Milestone;
            _connection = client.Connection;
        }
        public ObservableRepositoriesClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.Repository;
            _connection = client.Connection;
            Status = new ObservableCommitStatusClient(client);
            Hooks = new ObservableRepositoryHooksClient(client);
            Forks = new ObservableRepositoryForksClient(client);
#pragma warning disable CS0618 // Type or member is obsolete
            RepoCollaborators = new ObservableRepoCollaboratorsClient(client);
#pragma warning restore CS0618 // Type or member is obsolete
            Collaborator = new ObservableRepoCollaboratorsClient(client);
            Deployment = new ObservableDeploymentsClient(client);
            Statistics = new ObservableStatisticsClient(client);
            PullRequest = new ObservablePullRequestsClient(client);
#pragma warning disable CS0618 // Type or member is obsolete
            RepositoryComments = new ObservableRepositoryCommentsClient(client);
#pragma warning restore CS0618 // Type or member is obsolete
            Comment = new ObservableRepositoryCommentsClient(client);
#pragma warning disable CS0618 // Type or member is obsolete
            Commits = new ObservableRepositoryCommitsClient(client);
#pragma warning restore CS0618 // Type or member is obsolete
            Commit = new ObservableRepositoryCommitsClient(client);
            Release = new ObservableReleasesClient(client);
            DeployKeys = new ObservableRepositoryDeployKeysClient(client);
            Content = new ObservableRepositoryContentsClient(client);
            Merging = new ObservableMergingClient(client);
            Page = new ObservableRepositoryPagesClient(client);
        }
        static Repository CreateRepository(IGitHubClient github)
        {
            var repoName = Helper.MakeNameWithTimestamp("create-hooks-test");
            var repository = github.Repository.Create(new NewRepository(repoName) { AutoInit = true });

            return repository.Result;
        }
        public ObservablePullRequestReviewCommentReactionsClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.Reaction.PullRequestReviewComment;
            _connection = client.Connection;
        }
        public ObservableReferencesClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _reference = client.GitDatabase.Reference;
            _connection = client.Connection;
        }
示例#26
0
        public LogInViewModel(IScreen host, IGitHubClient ghClient)
        {
            this.HostScreen = host;
            this.GHClient = ghClient;

            // Only allow a submit when the user name is valid
            var validStuffTyped = this.WhenAny(x => x.UserName, x => x.Password,
                (user, pass) => !string.IsNullOrWhiteSpace(user.Value) && !string.IsNullOrWhiteSpace(pass.Value));

            Submit = new ReactiveCommand(validStuffTyped);

            //todo: better make a cancel or else you'll get very mad!
            //Submit.Subscribe(_ =>
            //{
            //    GHClient.Authorization.Create();
            //    //try
            //    //{
            //    //    //if (user != null)
            //    //    //{
            //    //    // Insert the user into the cache
            //    //    BlobCache.UserAccount.InsertObject<User>("MyUser", user);
            //    //    //}
            //    //}
            //    //catch (AuthorizationException authEx)
            //    //{
            //    //    Debug.Print("CRAP!");
            //    //    Debug.Print(authEx.Message);
            //    //    Debug.Print(authEx.StackTrace);
            //    //}
            //});

            MessageBus.Current.RegisterMessageSource(Submit);
        }
 public ReleaseNotesBuilder(IGitHubClient gitHubClient, string user, string repository, string milestoneTitle)
 {
     this.gitHubClient = gitHubClient;
     this.user = user;
     this.repository = repository;
     this.milestoneTitle = milestoneTitle;
 }
        /// <summary>
        /// Initializes a new User Followers API client.
        /// </summary>
        /// <param name="client">An <see cref="IGitHubClient" /> used to make the requests</param>
        public ObservableFollowersClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.User.Followers;
            _connection = client.Connection;
        }
示例#29
0
 public SearchClientTests()
 {
     _gitHubClient = new GitHubClient(new ProductHeaderValue("OctokitTests"))
     {
         Credentials = Helper.Credentials
     };
 }
        public ObservableUserEmailsClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.User.Email;
            _connection = client.Connection;
        }
示例#31
0
 public ReleaseNotes(IGitHubClient client, ILogger <ReleaseNotes> logger, string breakingLabel)
 {
     this.GitHubClient  = client;
     this.logger        = logger;
     this.breakingLabel = breakingLabel;
 }
        public ObservableFeedsClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.Activity.Feeds;
        }
示例#33
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="vendorKey">The unique key for this vendor.</param>
 /// <param name="client">The underlying GitHub API client.</param>
 public GitHubRepository(string vendorKey, IGitHubClient client)
     : base(vendorKey)
 {
     this.Client = client;
 }
示例#34
0
 public TheDeleteMethod()
 {
     _gitHub = Helper.GetAuthenticatedClient();
 }
示例#35
0
        private static async Task <DateTimeOffset?> GetWorkingStartTime(RepoDefinition repo, Issue issue, string[] workingLabels, IGitHubClient gitHubClient)
        {
            var workingLabelsOnThisIssue =
                issue.Labels
                .Where(label => workingLabels.Contains(label.Name, StringComparer.OrdinalIgnoreCase))
                .Select(label => label.Name);

            if (!workingLabelsOnThisIssue.Any())
            {
                // Item isn't in any Working state, so ignore it
                return(null);
            }

            // Find all "labeled" events for this issue
            var issueEvents = await gitHubClient.Issue.Events.GetAllForIssue(repo.Owner, repo.Name, issue.Number);

            foreach (var workingLabelOnThisIssue in workingLabelsOnThisIssue)
            {
                var labelEvent = issueEvents.LastOrDefault(
                    issueEvent =>
                    issueEvent.Event == EventInfoState.Labeled &&
                    string.Equals(issueEvent.Label.Name, workingLabelOnThisIssue, StringComparison.OrdinalIgnoreCase));

                if (labelEvent != null)
                {
                    // If an event where this label was applied was found, return the date on which it was applied
                    return(labelEvent.CreatedAt);
                }
            }

            return(null);
        }
示例#36
0
 public TheDeleteBranchProtectionMethod()
 {
     _github = Helper.GetAuthenticatedClient();
     _client = new ObservableRepositoryBranchesClient(_github);
 }
        internal async static Task <RepositoryContext> CreateRepositoryWithProtectedBranch(this IGitHubClient client)
        {
            // Create user owned repo
            var userRepo = new NewRepository(Helper.MakeNameWithTimestamp("protected-repo"))
            {
                AutoInit = true
            };
            var contextUserRepo = await client.CreateRepositoryContext(userRepo);

            // Protect master branch
            var update = new BranchProtectionSettingsUpdate(new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "build", "test" }), null, true);

            await client.Repository.Branch.UpdateBranchProtection(contextUserRepo.RepositoryOwner, contextUserRepo.RepositoryName, "master", update);

            return(contextUserRepo);
        }
示例#38
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="environment">The web hosting environment.</param>
        /// <param name="cache">The cache in which to store mod metadata.</param>
        /// <param name="configProvider">The config settings for mod update checks.</param>
        /// <param name="chucklefish">The Chucklefish API client.</param>
        /// <param name="github">The GitHub API client.</param>
        /// <param name="nexus">The Nexus API client.</param>
        public ModsApiController(IHostingEnvironment environment, IMemoryCache cache, IOptions <ModUpdateCheckConfig> configProvider, IChucklefishClient chucklefish, IGitHubClient github, INexusClient nexus)
        {
            this.ModDatabase = new ModToolkit().GetModDatabase(Path.Combine(environment.WebRootPath, "StardewModdingAPI.metadata.json"));
            ModUpdateCheckConfig config = configProvider.Value;

            this.WikiCompatibilityPageUrl = config.WikiCompatibilityPageUrl;

            this.Cache = cache;
            this.SuccessCacheMinutes = config.SuccessCacheMinutes;
            this.ErrorCacheMinutes   = config.ErrorCacheMinutes;
            this.VersionRegex        = config.SemanticVersionRegex;
            this.Repositories        =
                new IModRepository[]
            {
                new ChucklefishRepository(config.ChucklefishKey, chucklefish),
                new GitHubRepository(config.GitHubKey, github),
                new NexusRepository(config.NexusKey, nexus)
            }
            .ToDictionary(p => p.VendorKey, StringComparer.CurrentCultureIgnoreCase);
        }
示例#39
0
 public TheConvertFromMemberMethod()
 {
     _gitHub = Helper.GetAuthenticatedClient();
 }
示例#40
0
        private RepoTask <IReadOnlyList <Issue> > GetIssuesForRepo(RepoDefinition repo, IGitHubClient gitHubClient)
        {
            var repositoryIssueRequest = new RepositoryIssueRequest
            {
                State = ItemStateFilter.Open,
            };

            return(new RepoTask <IReadOnlyList <Issue> >
            {
                Repo = repo,
                Task = gitHubClient.Issue.GetAllForRepository(repo.Owner, repo.Name, repositoryIssueRequest),
            });
        }
示例#41
0
 private RepoTask <IReadOnlyList <PullRequest> > GetPullRequestsForRepo(RepoDefinition repo, IGitHubClient gitHubClient)
 {
     return(new RepoTask <IReadOnlyList <PullRequest> >
     {
         Repo = repo,
         Task = gitHubClient.PullRequest.GetAllForRepository(repo.Owner, repo.Name),
     });
 }
示例#42
0
 public TheRemoveReviewEnforcementMethod()
 {
     _github = Helper.GetAuthenticatedClient();
     _client = new ObservableRepositoryBranchesClient(_github);
 }
示例#43
0
 public RefitModel(IGitHubClient gitHubClient) =>
        public ObservableUserKeysClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.User.Keys;
        }
        public TheCreateReactionMethod()
        {
            _github = Helper.GetAuthenticatedClient();

            _context = _github.CreateRepositoryContext("public-repo").Result;
        }
示例#46
0
 public TheGetAllMethod()
 {
     _gitHub = Helper.GetAuthenticatedClient();
 }
示例#47
0
 protected override void PreStart()
 {
     _gitHubClient = _gitHubClientFactory();
 }
示例#48
0
 public TheGetAllMethod()
 {
     _githubClient = Substitute.For <IGitHubClient>();
     _client       = new ObservableReactionsClient(_githubClient);
 }
        public ObservableStatisticsClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, nameof(client));

            _client = client;
        }
        internal static async Task <RepositoryContext> CreateRepositoryContext(this IGitHubClient client, NewRepository newRepository)
        {
            var repo = await client.Repository.Create(newRepository);

            return(new RepositoryContext(repo));
        }
示例#51
0
 public CreateIssueActivity(IGitHubClient github) => _github = github;
 public TheGetLatestReleaseMethod()
 {
     _client        = Helper.GetAuthenticatedClient();
     _releaseClient = _client.Repository.Release;
 }
        internal static async Task <EnterpriseUserContext> CreateEnterpriseUserContext(this IGitHubClient client, NewUser newUser)
        {
            var user = await client.User.Administration.Create(newUser);

            return(new EnterpriseUserContext(user));
        }
 public ObservableGitDatabaseClient(IGitHubClient client)
 {
     Tag = new ObservableTagsClient(client);
 }
示例#55
0
        /// <inheritdoc />
        public IMessageHandler WithGitHubClient(IGitHubClient client)
        {
            this.GitHubClient = client ?? throw new ArgumentNullException(nameof(client));

            return(this);
        }
        internal static async Task <EnterpriseTeamContext> CreateEnterpriseTeamContext(this IGitHubClient client, string organization, NewTeam newTeam)
        {
            var team = await client.Organization.Team.Create(organization, newTeam);

            return(new EnterpriseTeamContext(team));
        }
示例#57
0
 public TheGetAllRepositoriesForCurrentMethod()
 {
     // Authenticate as a GitHubApp Installation
     _github = Helper.GetAuthenticatedGitHubAppInstallationForOwner(Helper.UserName);
 }
示例#58
0
 public TheGetAllRepositoriesForCurrentUserMethod()
 {
     // Need to Authenticate as User to Server but not possible without receiving redirect from github.com
     //_github = Helper.GetAuthenticatedUserToServer();
     _github = null;
 }
        internal async static Task <OrganizationRepositoryWithTeamContext> CreateOrganizationRepositoryWithProtectedBranch(this IGitHubClient client)
        {
            // Create organization owned repo
            var orgRepo = new NewRepository(Helper.MakeNameWithTimestamp("protected-org-repo"))
            {
                AutoInit = true
            };
            var contextOrgRepo = await client.CreateRepositoryContext(Helper.Organization, orgRepo);

            // Create team in org
            var contextOrgTeam = await client.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team")));

            // Grant team push access to repo
            await client.Organization.Team.AddRepository(
                contextOrgTeam.TeamId,
                contextOrgRepo.RepositoryOwner,
                contextOrgRepo.RepositoryName,
                new RepositoryPermissionRequest(Permission.Push));

            // Protect master branch
            var protection = new BranchProtectionSettingsUpdate(
                new BranchProtectionRequiredStatusChecksUpdate(true, new[] { "build", "test" }),
                new BranchProtectionPushRestrictionsUpdate(new BranchProtectionTeamCollection {
                contextOrgTeam.TeamName
            }),
                true);
            await client.Repository.Branch.UpdateBranchProtection(contextOrgRepo.RepositoryOwner, contextOrgRepo.RepositoryName, "master", protection);

            return(new OrganizationRepositoryWithTeamContext
            {
                RepositoryContext = contextOrgRepo,
                TeamContext = contextOrgTeam
            });
        }
        internal static async Task <RepositoryContext> CreateRepositoryContext(this IGitHubClient client, string organizationLogin, NewRepository newRepository)
        {
            var repo = await client.Repository.Create(organizationLogin, newRepository);

            return(new RepositoryContext(repo));
        }