Esempio n. 1
0
        public PluginCommandResponseMessage Execute(string args)
        {
            var response = new ContentResponse();
            var fileArgs = args.Deserialize <FileViewDiffArgs>();

            try
            {
                var revision = _repository.GetRevisionId(fileArgs.TpRevisionId);

                if (revision != null)
                {
                    var vcs = _vcsFactory.Get(revision.Profile);
                    response.Content = vcs.GetTextFileContent(revision.RevisionId.RevisionId, fileArgs.Path).Replace("\t", "    ");
                }

                return(new PluginCommandResponseMessage
                {
                    PluginCommandStatus = PluginCommandStatus.Succeed,
                    ResponseData = response.Serialize()
                });
            }
            catch
            {
                return(new PluginCommandResponseMessage
                {
                    PluginCommandStatus = PluginCommandStatus.Error,
                    ResponseData = "Unable to connect to a remote repository"
                });
            }
        }
        public PluginCommandResponseMessage Execute(string args)
        {
            var fileArgs = args.Deserialize <FileViewDiffArgs>();

            try
            {
                var revision = _repository.GetRevisionId(fileArgs.TpRevisionId);
                var diff     = new DiffResult();

                if (revision != null)
                {
                    var vcs = _vcsFactory.Get(revision.Profile);
                    diff = vcs.GetDiff(revision.RevisionId.RevisionId, fileArgs.Path);
                }

                return(new PluginCommandResponseMessage
                {
                    PluginCommandStatus = PluginCommandStatus.Succeed,
                    ResponseData = diff.Serialize()
                });
            }
            catch (Exception e)
            {
                _logger.Error("ViewDiff error", e);
                return(new PluginCommandResponseMessage
                {
                    PluginCommandStatus = PluginCommandStatus.Error,
                    ResponseData = "Unable to connect to a remote repository: {0}.".Fmt(e.Message)
                });
            }
        }