Ejemplo n.º 1
0
        public string GetRevision(string basePath, string repositoryName)
        {
            var url         = this.GetUrl(basePath, repositoryName);
            var infoCommand = new SvnCommand("info")
            {
                (SvnPath)url,
                new SvnCommandItem("show-item", "last-changed-revision"),
            };

            return(infoCommand.ReadLine());
        }
Ejemplo n.º 2
0
        public void Commit(string author, string comment, params LogPropertyInfo[] properties)
        {
            if (this.transactionName != null)
            {
                var diffCommand = new SvnCommand("diff")
                {
                    (SvnPath)this.BasePath,
                    new SvnCommandItem("patch-compatible")
                };
                var output = diffCommand.ReadLine();
                File.WriteAllText(this.transactionPatchPath, output);
                this.transactionMessageList.Add(comment);
                this.transactionPropertyList.AddRange(properties);
                return;
            }

            this.logService?.Debug($"repository committing {(SvnPath)this.BasePath}");
            var result        = string.Empty;
            var commentPath   = PathUtility.GetTempFileName();
            var propText      = SvnRepositoryProvider.GeneratePropertiesArgument(properties);
            var updateCommand = new SvnCommand("update")
            {
                (SvnPath)this.BasePath
            };
            var commitCommand = new SvnCommand("commit")
            {
                (SvnPath)this.BasePath,
                SvnCommandItem.FromMessage(comment),
                propText,
                SvnCommandItem.FromEncoding(Encoding.UTF8),
                SvnCommandItem.FromUsername(author),
            };

            try
            {
                if (this.needToUpdate == true)
                {
                    updateCommand.Run(this.logService);
                }

                result = commitCommand.Run(this.logService);
            }
            catch (Exception e)
            {
                this.logService?.Warn(e);
                updateCommand.Run(this.logService);
                result = commitCommand.Run(this.logService);
            }
            finally
            {
                this.needToUpdate = false;
                FileUtility.Delete(commentPath);
            }

            if (result.Trim() != string.Empty)
            {
                this.logService?.Debug(result);
                this.logService?.Debug($"repository committed {(SvnPath)this.BasePath}");
                this.info = SvnInfo.Run(this.BasePath);
                this.repositoryInfo.Revision         = this.info.LastChangedRevision;
                this.repositoryInfo.ModificationInfo = new SignatureDate(this.info.LastChangedAuthor, this.info.LastChangedDate);
            }
            else
            {
                this.logService?.Debug("repository no changes. \"{0}\"", this.BasePath);
            }
        }