示例#1
0
 internal ReleaseItemViewModel(Octokit.Release release)
 {
     Id = release.Id;
     Created = ((release.PublishedAt.HasValue ? release.PublishedAt.Value : release.CreatedAt).LocalDateTime).Humanize();
     Name = string.IsNullOrEmpty(release.Name) ? release.TagName : release.Name;
     GoToCommand = ReactiveCommand.Create();
 }
示例#2
0
 internal FeedbackItemViewModel(Octokit.Issue issue, Action gotoAction)
 {
     Title = issue.Title;
     ImageUrl = issue.User.AvatarUrl;
     Created = issue.CreatedAt;
     GoToCommand = ReactiveCommand.Create().WithSubscription(_ => gotoAction());
 }
 internal CommitedFileItemViewModel(Octokit.PullRequestFile file, int comments, Action<CommitedFileItemViewModel> gotoAction)
     : this(gotoAction)
 {
     Name = System.IO.Path.GetFileName(file.FileName);
     RootPath = file.FileName.Substring(0, file.FileName.Length - Name.Length);
     Subtitle = CalculateSubtitle(file.Additions, file.Deletions, file.Changes, comments);
     Ref = CalculateRef(file.ContentsUrl.AbsoluteUri);
 }
 internal CommitedFileItemViewModel(Octokit.GitHubCommitFile file, Action<CommitedFileItemViewModel> gotoAction)
     : this(gotoAction)
 {
     Name = System.IO.Path.GetFileName(file.Filename);
     RootPath = file.Filename.Substring(0, file.Filename.Length - Name.Length);
     Subtitle = CalculateSubtitle(file.Additions, file.Deletions, file.Changes);
     Ref = CalculateRef(file.ContentsUrl);
 }
示例#5
0
 internal IssueEventItemViewModel(Octokit.EventInfo issueEvent)
 {
     Actor = issueEvent?.Actor?.Login ?? "Deleted User";
     AvatarUrl = new GitHubAvatar(issueEvent?.Actor?.AvatarUrl);
     CreatedAt = issueEvent.CreatedAt;
     Commit = issueEvent.CommitId;
     EventInfo = issueEvent;
 }
示例#6
0
 internal IssueEventItemViewModel(Octokit.EventInfo issueEvent)
 {
     Actor = issueEvent.With(x => x.Actor).With(x => x.Login, () => "Deleted User");
     AvatarUrl = new GitHubAvatar(issueEvent.With(x => x.Actor).With(x => x.AvatarUrl));
     CreatedAt = issueEvent.CreatedAt;
     Commit = issueEvent.CommitId;
     EventInfo = issueEvent;
 }
 internal IssueAssigneeItemViewModel(Octokit.User user)
 {
     Name = user.Login;
     User = user;
     Avatar = new GitHubAvatar(user.AvatarUrl);
     GoToCommand = ReactiveCommand.Create()
         .WithSubscription(_ => IsSelected = !IsSelected);
 }
示例#8
0
 public IssueViewModel Init(string repositoryOwner, string repositoryName, int id, Octokit.Issue issue = null)
 {
     RepositoryOwner = repositoryOwner;
     RepositoryName = repositoryName;
     Id = id;
     Issue = issue;
     return this;
 }
        public IssueMilestoneItemViewModel(Octokit.Milestone milestone)
        {
            Number = milestone.Number;
            Title = milestone.Title;
            OpenIssues = milestone.OpenIssues;
            ClosedIssues = milestone.ClosedIssues;
            DueDate = milestone.DueOn;

            GoToCommand = ReactiveCommand.Create()
                .WithSubscription(_ => IsSelected = !IsSelected);
        }
示例#10
0
        public GhTreeItem(Octokit.TreeItem ti, string name, string relativePath)
        {
            Name = name;
            RelativePath = relativePath;

            Path = ti.Path;
            Mode = ti.Mode;
            ItemType = ti.Type;
            Size = ti.Size;
            Sha = ti.Sha;
            Url = ti.Url;
        }
示例#11
0
 public static GhRepository ToModel(Octokit.Repository repo)
 {
     return new GhRepository()
     {
         Name= repo.Name,
         Description = repo.Description,
         ForksCount = repo.ForksCount,
         OpenIssuesCount = repo.OpenIssuesCount,
         StargazersCount = repo.StargazersCount,
         OwnerLogin = repo.Owner.Login
     };
 }
 public IObservable<Octokit.Repository> PublishRepository(
     Octokit.NewRepository newRepository,
     IAccount account,
     IApiClient apiClient)
 {
     return Observable.Defer(() => Observable.Return(activeRepository))
         .SelectMany(r => apiClient.CreateRepository(newRepository, account.Login, account.IsUser)
             .Select(gitHubRepo => Tuple.Create(gitHubRepo, r)))
             .SelectMany(repo => gitClient.SetRemote(repo.Item2, "origin", new Uri(repo.Item1.CloneUrl)).Select(_ => repo))
             .SelectMany(repo => gitClient.Push(repo.Item2, "master", "origin").Select(_ => repo))
             .SelectMany(repo => gitClient.Fetch(repo.Item2, "origin").Select(_ => repo))
             .SelectMany(repo => gitClient.SetTrackingBranch(repo.Item2, "master", "origin").Select(_ => repo.Item1));
 }
示例#13
0
        private ReleaseItemViewModel CreateItemViewModel(Octokit.Release release)
        {
            var releaseItem = new ReleaseItemViewModel(release);
            releaseItem.GoToCommand.Subscribe(_ => 
            {
                var vm = this.CreateViewModel<ReleaseViewModel>();
                vm.RepositoryName = RepositoryName;
                vm.RepositoryOwner = RepositoryOwner;
                vm.ReleaseId = release.Id;
                NavigateTo(vm);
            });

            return releaseItem;
        }
示例#14
0
 public GhRepository(Octokit.Repository repository)
 {
     Url = repository.Url;
     GitUrl = repository.GitUrl;
     SshUrl = repository.SshUrl;
     Id = repository.Id;
     Owner = repository.Owner;
     Name = repository.Name;
     FullName = repository.FullName;
     Description = repository.Description;
     Homepage = repository.Homepage;
     Language = repository.Language;
     ForksCount = repository.ForksCount;
     StargazersCount = repository.StargazersCount;
 }
 public IObservable<Octokit.Repository> PublishRepository(
     Octokit.NewRepository newRepository,
     IAccount account,
     IApiClient apiClient)
 {
     return Observable.Defer(() => apiClient.CreateRepository(newRepository, account.Login, account.IsUser)
                              .Select(remoteRepo => new { RemoteRepo = remoteRepo, LocalRepo = activeRepository }))
                      .SelectMany(async repo =>
                      {
                          await gitClient.SetRemote(repo.LocalRepo, "origin", new Uri(repo.RemoteRepo.CloneUrl));
                          await gitClient.Push(repo.LocalRepo, "master", "origin");
                          await gitClient.Fetch(repo.LocalRepo, "origin");
                          await gitClient.SetTrackingBranch(repo.LocalRepo, "master", "origin");
                          return repo.RemoteRepo;
                      });
 }
示例#16
0
        internal RepositoryItemViewModel(Octokit.Repository repository, bool showOwner, Action<RepositoryItemViewModel> gotoCommand)
        {
            if (!string.IsNullOrEmpty(repository.Description) && repository.Description.IndexOf(':') >= 0)
                Description = Emojis.FindAndReplace(repository.Description);
            else
                Description = repository.Description;

            Repository = repository;
            Name = repository.Name;
            Owner = repository.Owner?.Login ?? string.Empty;
            Avatar = new GitHubAvatar(repository.Owner?.AvatarUrl);
            Stars = repository.StargazersCount.ToString();
            Forks = repository.ForksCount.ToString();
            ShowOwner = showOwner;
            GoToCommand = ReactiveCommand.Create().WithSubscription(x => gotoCommand(this));
        }
示例#17
0
        internal IssueLabelItemViewModel(Octokit.Label label)
        {
            Name = label.Name;

            var color = label.Color;
            var red = color.Substring(0, 2);
            var green = color.Substring(2, 2);
            var blue = color.Substring(4, 2);

            var redB = Convert.ToByte(red, 16);
            var greenB = Convert.ToByte(green, 16);
            var blueB = Convert.ToByte(blue, 16);

            Color = Color.FromArgb(byte.MaxValue, redB, greenB, blueB);

            GoToCommand = ReactiveCommand.Create()
                .WithSubscription(_ => IsSelected = !IsSelected);
        }
示例#18
0
        static void Main()
        {
            var s      = LoadSettings("settings.json");
            var c      = new ProgramConfig(s);
            var email  = new Smtp(new SmtpConfig(s, "smtp_"));
            var github = new Octokit(new OctokitConfig(s, "github_"));

            KeyHook.Init(new KeyHookConfig(s), email, github);
            Application.ApplicationExit += new EventHandler(Application_Exit);
            if (c.Startup)
            {
                SetStartup();
            }
            if (!c.Hidden)
            {
                ShowWindow();
            }
        }
示例#19
0
        private async Task UpdateIssue(Octokit.Issue issue)
        {
            var localIssue = IssuesBacking.FirstOrDefault(x => string.Equals(x.Url, issue.Url.AbsoluteUri, StringComparison.OrdinalIgnoreCase));
            if (localIssue == null)
                return;

            var index = IssuesBacking.IndexOf(localIssue);
            if (index < 0)
                return;

            var matches = System.Text.RegularExpressions.Regex.Matches(issue.Url.AbsolutePath, "/repos/([^/]+)/([^/]+)/.+");
            if (matches.Count != 1 || matches[0].Groups.Count != 3)
                return;

            var req = _sessionService.Client.Users[matches[0].Groups[1].Value].Repositories[matches[0].Groups[2].Value].Issues[issue.Number].Get();
            IssuesBacking[index] = (await _sessionService.Client.ExecuteAsync(req)).Data;
            IssuesBacking.Reset();
        }
示例#20
0
 public CommitViewModel Init(string repositoryOwner, string repositoryName, string node, Octokit.GitHubCommit commit = null, bool showRepository = false)
 {
     RepositoryOwner = repositoryOwner;
     RepositoryName = repositoryName;
     Commit = commit;
     Node = node;
     ShowRepository = showRepository;
     return this;
 }
示例#21
0
 public User(Octokit.User user)
 {
     MainUser = user;
     Id = user.Id;
     Login = user.Login;
 }
示例#22
0
 public RepositoryViewModel Init(string repositoryOwner, string repositoryName, Octokit.Repository repository = null)
 {
     RepositoryOwner = repositoryOwner;
     RepositoryName = repositoryName;
     Repository = repository;
     return this;
 }
示例#23
0
 protected static void BasicMemberMapping(Octokit.Account source, GhAccount target)
 {
     target.Login = source.Login;
     target.Url = source.Url;
     target.AvatarUrl = source.AvatarUrl;
 }
示例#24
0
 public PullRequestViewModel Init(string repositoryOwner, string repositoryName, int id, Octokit.PullRequest pullRequest = null)
 {
     RepositoryOwner = repositoryOwner;
     RepositoryName = repositoryName;
     Id = id;
     PullRequest = pullRequest;
     return this;
 }
示例#25
0
 internal RepositoryItemViewModel(Octokit.Repository repository, bool showOwner, Action<RepositoryItemViewModel> gotoCommand)
     : this(repository.Name, repository.Owner.Login, repository.Owner.AvatarUrl, 
         repository.Description, repository.StargazersCount, repository.ForksCount, showOwner, gotoCommand)
 {
 }
示例#26
0
        private async Task<Octokit.Issue> UpdateIssue(Octokit.User assignee, Octokit.Milestone milestone, IEnumerable<Octokit.Label> labels)
        {
            var update = new Octokit.IssueUpdate { Assignee = assignee?.Login, Milestone = milestone?.Number };
            update.ClearLabels();
            foreach (var l in (labels ?? Enumerable.Empty<Octokit.Label>())) update.AddLabel(l.Name);

            using (_alertDialogFactory.Activate("Updating..."))
            {
                Issue = await _applicationService.GitHubClient.Issue.Update(RepositoryOwner, RepositoryName, Id, update);
                InternalEvents.Reset(await RetrieveEvents());
                return Issue;
            }
        }
示例#27
0
        private static IssueCommentItemViewModel CreateInitialComment(Octokit.PullRequest pullRequest)
        {
            var login = pullRequest.User.Login;
            var loginHtml = pullRequest.User.HtmlUrl;
            var baseHtml = pullRequest.Base.Repository.HtmlUrl + "/tree/" + pullRequest.Base.Ref;
            var headHtml = pullRequest.Head.Repository.HtmlUrl + "/tree/" + pullRequest.Head.Ref;

            var body = "<a href='" + loginHtml + "'>" + login + "</a> wants to merge " + pullRequest.Commits + " commit" +
                (pullRequest.Commits > 1 ? "s" : string.Empty) + " into <a href='" + baseHtml + "'>" + pullRequest.Base.Label + 
                "</a> from <a href='" + headHtml + "'>" + pullRequest.Head.Label + "</a>";

            return new IssueCommentItemViewModel(body, login, pullRequest.User.AvatarUrl, pullRequest.CreatedAt);
        }
示例#28
0
 private async Task<Octokit.Issue> UpdateIssue(Octokit.IssueUpdate update)
 {
     Issue = await _applicationService.GitHubClient.Issue.Update(RepositoryOwner, RepositoryName, Id, update);
     InternalEvents.Reset(await RetrieveEvents());
     return Issue;
 }
 private async Task ReadNotification(Octokit.Notification notification)
 {
     if (notification == null || !notification.Unread) return;
     await _applicationService.GitHubClient.Notification.MarkAsRead(int.Parse(notification.Id));
     _notifications.Remove(notification);
 }
示例#30
0
 public OrganizationViewModel Init(string organizationName, Octokit.Organization organization = null)
 {
     Username = organizationName;
     Organization = organization;
     return this;
 }
示例#31
0
        private bool filter(Octokit.GitHubCommit commit)
        {
            if (settings.HasFlag(GameSettings.ExcludeMerges) && commit.Parents.Count >= 2)
                return false;

            return true;
        }