예제 #1
0
            public Task <CodeLensDataPointDescriptor> GetDataAsync(CodeLensDescriptorContext context, CancellationToken token)
            {
                try
                {
                    Changelist commit = HelixUtility.GetLastCommit(rep, descriptor.FilePath);
                    if (commit == null)
                    {
                        return(Task.FromResult <CodeLensDataPointDescriptor>(null));
                    }
                    CodeLensDataPointDescriptor response = new CodeLensDataPointDescriptor()
                    {
                        Description = commit.OwnerName, //commit.Author.Name,
                        TooltipText = $"Last change committed by {commit.OwnerName} at {commit.ModifiedDate.ToString(CultureInfo.CurrentCulture)}",
                        IntValue    = null,             // no int value
                        ImageId     = GetCommitTypeIcon(commit),
                    };

                    return(Task.FromResult(response));
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(
                        "file: " + descriptor.FilePath + "\r\n" +
                        "port: " + this.rep.Server.Address + "\r\n" +
                        "user: "******"\r\n" +
                        "client: " + this.rep.Connection.Client.Name + "\r\n" +
                        "Exception:" + "\r\n" + ex.ToString());
                    return(Task.FromResult <CodeLensDataPointDescriptor>(null));
                }
            }
예제 #2
0
        public Task <bool> CanCreateDataPointAsync(CodeLensDescriptor descriptor, CodeLensDescriptorContext context, CancellationToken token)
        {
            Debug.Assert(descriptor != null);
            var Repo = HelixUtility.GetRepository(descriptor.FilePath, out string repoRoot,
                                                  out Changelist latest);

            return(Task.FromResult <bool>(Repo != null && latest != null));
        }
예제 #3
0
            public Task <CodeLensDetailsDescriptor> GetDetailsAsync(CodeLensDescriptorContext context, CancellationToken token)
            {
                // get the most recent 5 commits
                var commits = HelixUtility.GetCommits(this.rep, this.descriptor.FilePath, 5).AsEnumerable();

                if (commits == null || commits.Count() == 0)
                {
                    return(Task.FromResult <CodeLensDetailsDescriptor>(null));
                }

                var headers = new List <CodeLensDetailHeaderDescriptor>()
                {
                    new CodeLensDetailHeaderDescriptor()
                    {
                        UniqueName = "CommitType",
                        Width      = 22,
                    },
                    new CodeLensDetailHeaderDescriptor()
                    {
                        UniqueName  = "Changelist",
                        DisplayName = "Changelist",
                        Width       = 100, // fixed width
                    },
                    new CodeLensDetailHeaderDescriptor()
                    {
                        UniqueName  = "CommitDescription",
                        DisplayName = "Description",
                        Width       = 0.66666, // use 2/3 of the remaining width
                    },
                    new CodeLensDetailHeaderDescriptor()
                    {
                        UniqueName  = "CommitAuthor",
                        DisplayName = "Author",
                        Width       = 0.33333, // use 1/3 of the remaining width
                    },
                    new CodeLensDetailHeaderDescriptor()
                    {
                        UniqueName  = "CommitDate",
                        DisplayName = "Date",
                        Width       = 85, // fixed width
                    }
                };

                var entries = commits.Select(
                    commit => new CodeLensDetailEntryDescriptor()
                {
                    Fields = new List <CodeLensDetailEntryField>()
                    {
                        new CodeLensDetailEntryField()
                        {
                            ImageId = GetCommitTypeIcon(commit),
                        },
                        new CodeLensDetailEntryField()
                        {
                            Text = commit.Id.ToString(),    //commit.Id.Sha.Substring(0, 8),
                        },
                        new CodeLensDetailEntryField()
                        {
                            Text = commit.Description.Length > 50 ?
                                   commit.Description.Replace(System.Environment.NewLine, " ").Substring(0, 50) + "..." :
                                   commit.Description.Replace(System.Environment.NewLine, " "),//commit.MessageShort,
                        },
                        new CodeLensDetailEntryField()
                        {
                            Text = commit.OwnerName,    //commit.Author.Name,
                        },
                        new CodeLensDetailEntryField()
                        {
                            Text = commit.ModifiedDate.ToString(@"MM\/dd\/yyyy", CultureInfo.CurrentCulture),    //commit.Author.When.ToString(@"MM\/dd\/yyyy", CultureInfo.CurrentCulture),
                        },
                    },
                    Tooltip           = commit.Description,//commit.Message,
                    NavigationCommand = new CodeLensDetailEntryCommand()
                    {
                        CommandSet  = new Guid("f3cb9f10-281b-444f-a14e-de5de36177cd"),
                        CommandId   = 0x0100,
                        CommandName = "Helix.NavigateToChangelist",
                    },
                    //NavigationCommandArgs = new List<object>() { commit.Id.Sha },
                    NavigationCommandArgs = new List <object>()
                    {
                        commit.Id.ToString()
                    },
                });

                var result = new CodeLensDetailsDescriptor();

                result.Headers = headers;
                result.Entries = entries;
                List <CodeLensDetailPaneCommand> PaneNavigationCommands = new List <CodeLensDetailPaneCommand>();

                CodeLensDetailPaneCommand historyCmd = new CodeLensDetailPaneCommand();

                historyCmd.CommandId             = new CodeLensDetailEntryCommand();
                historyCmd.CommandId.CommandSet  = new Guid("f3cb9f10-281b-444f-a14e-de5de36177cd");
                historyCmd.CommandId.CommandId   = 0x1005;
                historyCmd.CommandId.CommandName = "Helix.ShowHistory";
                historyCmd.CommandDisplayName    = "Show History";
                PaneNavigationCommands.Add(historyCmd);
                if (timelapseExists())
                {
                    CodeLensDetailPaneCommand timeLapseViewCmd = new CodeLensDetailPaneCommand();
                    timeLapseViewCmd.CommandId             = new CodeLensDetailEntryCommand();
                    timeLapseViewCmd.CommandId.CommandSet  = new Guid("f3cb9f10-281b-444f-a14e-de5de36177cd");
                    timeLapseViewCmd.CommandId.CommandId   = 0x1010;
                    timeLapseViewCmd.CommandId.CommandName = "Helix.TimeLapseView";
                    timeLapseViewCmd.CommandDisplayName    = "Time-lapse View";
                    timeLapseViewCmd.CommandArgs           = new List <object>()
                    {
                        this.descriptor.FilePath
                    };
                    PaneNavigationCommands.Add(timeLapseViewCmd);
                }

                result.PaneNavigationCommands = PaneNavigationCommands;
                return(Task.FromResult(result));
            }
예제 #4
0
 public HelixSubmittedChangelistDataPoint(CodeLensDescriptor descriptor)
 {
     this.descriptor = descriptor ?? throw new ArgumentNullException(nameof(descriptor));
     this.rep        = HelixUtility.GetRepository(descriptor.FilePath, out this.ws_root,
                                                  out Changelist latest);
 }