Esempio n. 1
0
 public PullRequest(Uri url, Uri htmlUrl, Uri diffUrl, Uri patchUrl, Uri issueUrl, Uri statusesUrl, int number, ItemState state, string title, string body, DateTimeOffset createdAt, DateTimeOffset updatedAt, DateTimeOffset? closedAt, DateTimeOffset? mergedAt, GitReference head, GitReference @base, User user, User assignee, bool? mergeable, User mergedBy, int comments, int commits, int additions, int deletions, int changedFiles, Milestone milestone)
 {
     Url = url;
     HtmlUrl = htmlUrl;
     DiffUrl = diffUrl;
     PatchUrl = patchUrl;
     IssueUrl = issueUrl;
     StatusesUrl = statusesUrl;
     Number = number;
     State = state;
     Title = title;
     Body = body;
     CreatedAt = createdAt;
     UpdatedAt = updatedAt;
     ClosedAt = closedAt;
     MergedAt = mergedAt;
     Head = head;
     Base = @base;
     User = user;
     Assignee = assignee;
     Mergeable = mergeable;
     MergedBy = mergedBy;
     Comments = comments;
     Commits = commits;
     Additions = additions;
     Deletions = deletions;
     ChangedFiles = changedFiles;
     Milestone = milestone;
 }
Esempio n. 2
0
        public IssueMilestonesViewModel(
            Func<Task<IReadOnlyList<Milestone>>> loadMilestones,
            Func<Task<Milestone>> loadSelectedFunc,
            Func<Milestone, Task> saveFunc)
        {
            var milestones = new ReactiveList<Milestone>();
            Milestones = milestones.CreateDerivedCollection(x => CreateItemViewModel(x));

            this.WhenAnyValue(x => x.Selected)
                .Subscribe(x => {
                    foreach (var a in Milestones)
                        a.IsSelected = a.Number == x?.Number;
                });

            DismissCommand = ReactiveCommand.Create();

            SaveCommand = ReactiveCommand.CreateAsyncTask(_ => {
                DismissCommand.ExecuteIfCan();
                return _selected != _previouslySelected ? saveFunc(_selected) : Task.FromResult(0);
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(async _ => {
                _previouslySelected = Selected = await loadSelectedFunc();
                milestones.Reset(await loadMilestones());
            });
        }
 string GetCommitsLink(Milestone previousMilestone)
 {
     if (previousMilestone == null)
     {
         return string.Format("https://github.com/{0}/{1}/commits/{2}", user, repository, targetMilestone.Title);
     }
     return string.Format("https://github.com/{0}/{1}/compare/{2}...{3}", user, repository, previousMilestone.Title, targetMilestone.Title);
 }
Esempio n. 4
0
 private IssueMilestoneItemViewModel CreateItemViewModel(Milestone x)
 {
     var vm = new IssueMilestoneItemViewModel(x);
     vm.IsSelected = x.Number == Selected?.Number;
     vm.GoToCommand.Subscribe(_ => {
         Selected = vm.IsSelected ? x : null;
         SaveCommand.ExecuteIfCan();
     });
     return vm;
 }
Esempio n. 5
0
 public IssuesFilterModel(User assignee = null, string creator = null, string mentioned = null, IReadOnlyList<Label> labels = null,
     Milestone milestone = null, IssueState issueState = IssueState.Open, 
     IssueSort sortType = IssueSort.None, bool ascending = false)
 {
     Assignee = assignee;
     Creator = creator;
     Mentioned = mentioned;
     Labels = labels;
     this.Milestone = milestone;
     this.IssueState = issueState;
     SortType = sortType;
     Ascending = ascending;
 }
 public TimelineEventInfo(int id, string url, User actor, string commitId, EventInfoState @event, DateTimeOffset createdAt, Label label, User assignee, Milestone milestone, SourceInfo source, RenameInfo rename)
 {
     Id = id;
     Url = url;
     Actor = actor;
     CommitId = commitId;
     Event = @event;
     CreatedAt = createdAt;
     Label = label;
     Assignee = assignee;
     Milestone = milestone;
     Source = source;
     Rename = rename;
 }
Esempio n. 7
0
 public Issue(Uri url, Uri htmlUrl, int number, ItemState state, string title, string body, User user, IReadOnlyList<Label> labels, User assignee, Milestone milestone, int comments, PullRequest pullRequest, DateTimeOffset? closedAt, DateTimeOffset createdAt, DateTimeOffset? updatedAt)
 {
     Url = url;
     HtmlUrl = htmlUrl;
     Number = number;
     State = state;
     Title = title;
     Body = body;
     User = user;
     Labels = labels;
     Assignee = assignee;
     Milestone = milestone;
     Comments = comments;
     PullRequest = pullRequest;
     ClosedAt = closedAt;
     CreatedAt = createdAt;
     UpdatedAt = updatedAt;
 }
 public static async Task<IEnumerable<Issue>> AllIssuesForMilestone(this GitHubClient gitHubClient, Milestone milestone)
 {
     var closedIssueRequest = new RepositoryIssueRequest
     {
         Milestone = milestone.Number.ToString(CultureInfo.InvariantCulture),
         State = ItemState.Closed
     };
     var openIssueRequest = new RepositoryIssueRequest
     {
         Milestone = milestone.Number.ToString(CultureInfo.InvariantCulture),
         State = ItemState.Open
     };
     var parts = milestone.Url.AbsolutePath.Split('/');
     var user = parts[2];
     var repository = parts[3];
     var closedIssues = await gitHubClient.Issue.GetForRepository(user, repository, closedIssueRequest);
     var openIssues = await gitHubClient.Issue.GetForRepository(user, repository, openIssueRequest);
     return openIssues.Union(closedIssues);
 }
        public async Task<int> GetNumberOfCommitsBetween(Milestone previousMilestone, Milestone currentMilestone)
        {
            try
            {
                if (previousMilestone == null)
                {
                    var gitHubClientRepositoryCommitsCompare = await gitHubClient.Repository.Commits.Compare(user, repository, "master", currentMilestone.Title);
                    return gitHubClientRepositoryCommitsCompare.AheadBy;
                }

                var compareResult = await gitHubClient.Repository.Commits.Compare(user, repository, previousMilestone.Title, "master");
                return compareResult.AheadBy;
            }
            catch (NotFoundException)
            {
                //If there is not tag yet the Compare will return a NotFoundException
                //we can safely ignore
                return 0;
            }
        }
Esempio n. 10
0
 public PullRequest(long id, string nodeId, string url, string htmlUrl, string diffUrl, string patchUrl, string issueUrl, string statusesUrl, int number, ItemState state, string title, string body, DateTimeOffset createdAt, DateTimeOffset updatedAt, DateTimeOffset?closedAt, DateTimeOffset?mergedAt, GitReference head, GitReference @base, User user, User assignee, IReadOnlyList <User> assignees, bool draft, bool?mergeable, MergeableState?mergeableState, User mergedBy, string mergeCommitSha, int comments, int commits, int additions, int deletions, int changedFiles, Milestone milestone, bool locked, bool?maintainerCanModify, IReadOnlyList <User> requestedReviewers, IReadOnlyList <Label> labels)
 {
     Id                  = id;
     NodeId              = nodeId;
     Url                 = url;
     HtmlUrl             = htmlUrl;
     DiffUrl             = diffUrl;
     PatchUrl            = patchUrl;
     IssueUrl            = issueUrl;
     StatusesUrl         = statusesUrl;
     Number              = number;
     State               = state;
     Title               = title;
     Body                = body;
     CreatedAt           = createdAt;
     UpdatedAt           = updatedAt;
     ClosedAt            = closedAt;
     MergedAt            = mergedAt;
     Head                = head;
     Base                = @base;
     User                = user;
     Assignee            = assignee;
     Assignees           = assignees;
     Draft               = draft;
     Mergeable           = mergeable;
     MergeableState      = mergeableState;
     MergedBy            = mergedBy;
     MergeCommitSha      = mergeCommitSha;
     Comments            = comments;
     Commits             = commits;
     Additions           = additions;
     Deletions           = deletions;
     ChangedFiles        = changedFiles;
     Milestone           = milestone;
     Locked              = locked;
     MaintainerCanModify = maintainerCanModify;
     RequestedReviewers  = requestedReviewers;
     Labels              = labels;
 }
Esempio n. 11
0
 public Issue(Uri url, Uri htmlUrl, Uri commentsUrl, Uri eventsUrl, int number, ItemState state, string title, string body, User user, IReadOnlyList <Label> labels, User assignee, Milestone milestone, int comments, PullRequest pullRequest, DateTimeOffset?closedAt, DateTimeOffset createdAt, DateTimeOffset?updatedAt, int id, bool locked, Repository repository)
 {
     Id          = id;
     Url         = url;
     HtmlUrl     = htmlUrl;
     CommentsUrl = commentsUrl;
     EventsUrl   = eventsUrl;
     Number      = number;
     State       = state;
     Title       = title;
     Body        = body;
     User        = user;
     Labels      = labels;
     Assignee    = assignee;
     Milestone   = milestone;
     Comments    = comments;
     PullRequest = pullRequest;
     ClosedAt    = closedAt;
     CreatedAt   = createdAt;
     UpdatedAt   = updatedAt;
     Locked      = locked;
     Repository  = repository;
 }
        protected GitHubApiBase(ICache settingsCache)
        {
            if (settingsCache == null)
                throw new ArgumentNullException("settingsCache");

            _userFilterType = UserFilterType.All;
            UserFilters = new List<UserFilterType>();
            foreach (UserFilterType value in Enum.GetValues(typeof(UserFilterType)))
            {
                UserFilters.Add(value);
            }

            _allLabels = new Label(null, "All Labels", "FFFFFFFF");
            AllMilestones = new Milestone(null, 0, ItemState.All, "All Milestones", "", null, 0, 0, DateTimeOffset.UtcNow, null);
            NoMilestone = new Milestone(null, -1, ItemState.All, "No Milestone", "", null, 0, 0, DateTimeOffset.UtcNow, null);

            SettingsCache = settingsCache;
            Repositories = new BindingList<RepositoryWrapper>();
            Organizations = new BindingList<Organization>();
            AllIssues = new BindingList<Issue>();
            Labels = new BindingList<Label>();
            Milestones = new BindingList<Milestone>();
        }
Esempio n. 13
0
 public Issue(Uri url, Uri htmlUrl, Uri commentsUrl, Uri eventsUrl, int number, ItemState state, string title, string body, User closedBy, User user, IReadOnlyList<Label> labels, User assignee, Milestone milestone, int comments, PullRequest pullRequest, DateTimeOffset? closedAt, DateTimeOffset createdAt, DateTimeOffset? updatedAt, int id, bool locked, Repository repository)
 {
     Id = id;
     Url = url;
     HtmlUrl = htmlUrl;
     CommentsUrl = commentsUrl;
     EventsUrl = eventsUrl;
     Number = number;
     State = state;
     Title = title;
     Body = body;
     ClosedBy = closedBy;
     User = user;
     Labels = labels;
     Assignee = assignee;
     Milestone = milestone;
     Comments = comments;
     PullRequest = pullRequest;
     ClosedAt = closedAt;
     CreatedAt = createdAt;
     UpdatedAt = updatedAt;
     Locked = locked;
     Repository = repository;
 }
Esempio n. 14
0
 public PullRequest(long id, Uri url, Uri htmlUrl, Uri diffUrl, Uri patchUrl, Uri issueUrl, Uri statusesUrl, int number, ItemState state, string title, string body, DateTimeOffset createdAt, DateTimeOffset updatedAt, DateTimeOffset?closedAt, DateTimeOffset?mergedAt, GitReference head, GitReference @base, User user, User assignee, IReadOnlyList <User> assignees, bool?mergeable, User mergedBy, string mergeCommitSha, int comments, int commits, int additions, int deletions, int changedFiles, Milestone milestone, bool locked)
 {
     Id             = id;
     Url            = url;
     HtmlUrl        = htmlUrl;
     DiffUrl        = diffUrl;
     PatchUrl       = patchUrl;
     IssueUrl       = issueUrl;
     StatusesUrl    = statusesUrl;
     Number         = number;
     State          = state;
     Title          = title;
     Body           = body;
     CreatedAt      = createdAt;
     UpdatedAt      = updatedAt;
     ClosedAt       = closedAt;
     MergedAt       = mergedAt;
     Head           = head;
     Base           = @base;
     User           = user;
     Assignee       = assignee;
     Assignees      = assignees;
     Mergeable      = mergeable;
     MergedBy       = mergedBy;
     MergeCommitSha = mergeCommitSha;
     Comments       = comments;
     Commits        = commits;
     Additions      = additions;
     Deletions      = deletions;
     ChangedFiles   = changedFiles;
     Milestone      = milestone;
     Locked         = locked;
 }
Esempio n. 15
0
 public Issue(Uri url, Uri htmlUrl, int number, ItemState state, string title, string body, User user, IReadOnlyList <Label> labels, User assignee, Milestone milestone, int comments, PullRequest pullRequest, DateTimeOffset?closedAt, DateTimeOffset createdAt, DateTimeOffset?updatedAt)
 {
     Url         = url;
     HtmlUrl     = htmlUrl;
     Number      = number;
     State       = state;
     Title       = title;
     Body        = body;
     User        = user;
     Labels      = labels;
     Assignee    = assignee;
     Milestone   = milestone;
     Comments    = comments;
     PullRequest = pullRequest;
     ClosedAt    = closedAt;
     CreatedAt   = createdAt;
     UpdatedAt   = updatedAt;
 }
Esempio n. 16
0
 public MilestoneViewModel(Milestone milestone)
 {
     this.milestone = milestone;
 }
 void GetTargetMilestone()
 {
     targetMilestone = milestones.FirstOrDefault(x => x.Title == milestoneTitle);
     if (targetMilestone == null)
     {
         throw new Exception(string.Format("Could not find milestone for '{0}'.", milestoneTitle));
     }
 }
 async Task<List<Issue>> GetIssues(Milestone milestone)
 {
     var issues = await gitHubClient.GetIssues(milestone);
     foreach (var issue in issues)
     {
         CheckForValidLabels(issue);
     }
     return issues;
 }
Esempio n. 19
0
        public override IReadOnlyList <string> MergedQualifiers()
        {
            var parameters = new List <string>();

            if (Type != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "type:{0}",
                                             Type.ToParameter()));
            }

            if (In != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "in:{0}",
                                             string.Join(",", In.Select(i => i.ToParameter()))));
            }

            if (Author.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "author:{0}", Author));
            }

            if (Assignee.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "assignee:{0}", Assignee));
            }

            if (Mentions.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "mentions:{0}", Mentions));
            }

            if (Commenter.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "commenter:{0}", Commenter));
            }

            if (Involves.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "involves:{0}", Involves));
            }

            if (Team.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "team:{0}", Team));
            }

            if (State.HasValue)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "state:{0}", State.Value.ToParameter()));
            }

            if (Labels != null)
            {
                parameters.AddRange(Labels.Select(label => string.Format(CultureInfo.InvariantCulture, "label:\"{0}\"", label)));
            }

            if (No.HasValue)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "no:{0}", No.Value.ToParameter()));
            }

            if (Language != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "language:\"{0}\"", Language.ToParameter()));
            }

            if (Is != null)
            {
                parameters.AddRange(Is.Select(x => string.Format(CultureInfo.InvariantCulture, "is:{0}", x.ToParameter())));
            }

            if (Created != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "created:{0}", Created));
            }

            if (Updated != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "updated:{0}", Updated));
            }

            if (Merged != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "merged:{0}", Merged));
            }

            if (Status.HasValue)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "status:{0}", Status.Value.ToParameter()));
            }

            if (Head.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "head:{0}", Head));
            }

            if (Base.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "base:{0}", Base));
            }

            if (Closed != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "closed:{0}", Closed));
            }

            if (Comments != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "comments:{0}", Comments));
            }

            if (User.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "user:{0}", User));
            }

            if (Repos.Any())
            {
                var invalidFormatRepos = Repos.Where(x => !x.IsNameWithOwnerFormat());
                if (invalidFormatRepos.Any())
                {
                    throw new RepositoryFormatException(invalidFormatRepos);
                }

                parameters.AddRange(Repos.Select(x => string.Format(CultureInfo.InvariantCulture, "repo:{0}", x)));
            }

            if (Milestone.IsNotBlank())
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "milestone:\"{0}\"", Milestone.EscapeDoubleQuotes()));
            }

            if (Archived != null)
            {
                parameters.Add(string.Format(CultureInfo.InvariantCulture, "archived:{0}", Archived.ToString().ToLower()));
            }

            // Add any exclusion parameters
            if (Exclusions != null)
            {
                parameters.AddRange(Exclusions.MergedQualifiers());
            }

            return(new ReadOnlyCollection <string>(parameters));
        }
        private string GetCommitsLink(Milestone previousMilestone)
        {
            if (previousMilestone == null)
            {
                return string.Format(CultureInfo.InvariantCulture, "https://github.com/{0}/{1}/commits/{2}", this.user, this.repository, this.targetMilestone.Title);
            }

            return string.Format(CultureInfo.InvariantCulture, "https://github.com/{0}/{1}/compare/{2}...{3}", this.user, this.repository, previousMilestone.Title, this.targetMilestone.Title);
        }
Esempio n. 21
0
 public Issue(string url, string htmlUrl, string commentsUrl, string eventsUrl, int number, ItemState state, string title, string body, User closedBy, User user, IReadOnlyList<Label> labels, User assignee, IReadOnlyList<User> assignees, Milestone milestone, int comments, PullRequest pullRequest, DateTimeOffset? closedAt, DateTimeOffset createdAt, DateTimeOffset? updatedAt, int id, string nodeId, bool locked, Repository repository, ReactionSummary reactions)
 {
     Id = id;
     NodeId = nodeId;
     Url = url;
     HtmlUrl = htmlUrl;
     CommentsUrl = commentsUrl;
     EventsUrl = eventsUrl;
     Number = number;
     State = state;
     Title = title;
     Body = body;
     ClosedBy = closedBy;
     User = user;
     Labels = labels;
     Assignee = assignee;
     Assignees = assignees;
     Milestone = milestone;
     Comments = comments;
     PullRequest = pullRequest;
     ClosedAt = closedAt;
     CreatedAt = createdAt;
     UpdatedAt = updatedAt;
     Locked = locked;
     Repository = repository;
     Reactions = reactions;
 }
 public Task<int> GetNumberOfCommitsBetween(Milestone previousMilestone, Milestone currentMilestone)
 {
     return Task.FromResult(NumberOfCommits);
 }
 public Task<List<Issue>> GetIssues(Milestone targetMilestone)
 {
     return Task.FromResult(Issues);
 }
Esempio n. 24
0
        public void SetUp()
        {
            var cache = new Mock<ICache>().Object;
            _moq = new Mock<GitHubApiBase>(cache);
            _api = _moq.Object;

            _label = new Label(null, "One", "");

            _milestone = new Milestone(null, 1, ItemState.All, "1.0", "", null, 1, 1, DateTimeOffset.Now, null, null);

            _issue = new Issue(null, null, null, 1, ItemState.Open, "Title one", "Body one", null, new List<Label>(new[] {_label}),
                null, _milestone, 1, null, null, DateTimeOffset.Now, null);
            _api.AllIssues.Add(_issue);

            var issue2 = new Issue(null, null, null, 2, ItemState.Open, "Two", "Two", null, new List<Label>(),
                null, new Milestone(null, 2, ItemState.All, "2.0", "", null, 1, 1, DateTimeOffset.Now, null, null), 1, null, null, DateTimeOffset.Now, null);
            _api.AllIssues.Add(issue2);

            var issue3 = new Issue(null, null, null, 3, ItemState.Open, "Three", "Three", null, new List<Label>(),
                null, null, 1, null, null, DateTimeOffset.Now, null);
            _api.AllIssues.Add(issue3);
        }
Esempio n. 25
0
 public Milestone(Octokit.Milestone milestone) : base(milestone.Title, milestone.Description)
 {
     DueOn = milestone.DueOn;
 }
 public async Task<List<Issue>> GetIssues(Milestone targetMilestone)
 {
     var allIssues = await gitHubClient.AllIssuesForMilestone(targetMilestone);
     return allIssues.Where(x => x.State == ItemState.Closed).ToList();
 }
 public override void GetMilestones()
 {
     var milestone = new Milestone(null, 1, ItemState.All, "v1.0", "The first release", null, 1, 0, DateTimeOffset.Now, DateTimeOffset.Now.AddDays(1));
     Milestone = milestone;
     Milestones.Add(milestone);
 }
 /// <summary>
 /// Milestones don't override Equals, so we need to find the one in
 /// the main collection and add it so that reference equals works
 /// for binding
 /// </summary>
 /// <param name="milestone"></param>
 private void SetMilestone(Milestone milestone)
 {
     if (milestone == null)
     {
         Milestone = null;
         return;
     }
     Milestone = (from m in Milestones
                  where m.Url == milestone.Url
                  select m).FirstOrDefault();
 }
 public TimelineEventInfo(long id, string nodeId, string url, User actor, string commitId, EventInfoState @event, DateTimeOffset createdAt, Label label, User assignee, Milestone milestone, SourceInfo source, RenameInfo rename)
 {
     Id        = id;
     NodeId    = nodeId;
     Url       = url;
     Actor     = actor;
     CommitId  = commitId;
     Event     = @event;
     CreatedAt = createdAt;
     Label     = label;
     Assignee  = assignee;
     Milestone = milestone;
     Source    = source;
     Rename    = rename;
 }
        private void GetTargetMilestone()
        {
            this.targetMilestone = this.milestones.FirstOrDefault(x => x.Title == this.milestoneTitle);

            if (this.targetMilestone == null)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Could not find milestone for '{0}'.", this.milestoneTitle));
            }
        }