コード例 #1
0
        private async Task<PRRequestModel> GetModel(WebUserNotifier webUserNotifier, PRRequestModel model, string accessToken)
        {
            if (model == null)
            {
                model = new PRRequestModel();
            }

            var username = await GetGithubUserName();

            var branchFetcher = new BranchFetcher(webUserNotifier);
            var branches = await branchFetcher.GetAllBranchNames(accessToken, username, "mi");
            var availableTargetBranches = await branchFetcher.GetAllBranchNames(accessToken, "grantadesign", "mi");

            var repositoryFetcher = new RepositoryFetcher(webUserNotifier);
            var repositories = await repositoryFetcher.GetAllRepositoryNames(accessToken, "grantadesign");

            model.Repositories = repositories;
            model.Repository = "mi";

            model.Branches = branches;
            model.AvailableTargetBranches = availableTargetBranches;
            model.Messages = webUserNotifier.Messages;

            return model;
        }
コード例 #2
0
        public async Task<ActionResult> FetchBranches(string repository)
        {
            var accessToken = await GetGithubToken();
            var username = await GetGithubUserName();

            var branchFetcher = new BranchFetcher(new WebUserNotifier());

            IEnumerable<string> branches;

            try
            {
                branches = await branchFetcher.GetAllBranchNames(accessToken, username, repository);
            }
            catch (Exception)
            {
                return Json(new[] {"Could not fetch branches"});
            }

            return Json(branches.ToArray());
        }