Пример #1
0
        public string GetRevision(string basePath, string repositoryName)
        {
            var revparseCommand = new GitCommand(basePath, "rev-parse")
            {
                repositoryName,
            };

            return(revparseCommand.ReadLine());
        }
Пример #2
0
        public void Commit(string author, string comment, params LogPropertyInfo[] properties)
        {
            if (this.transactionName != null)
            {
                var diffCommand = new GitCommand(this.BasePath, "diff")
                {
                    "HEAD",
                    new GitCommandItem("stat"),
                    new GitCommandItem("binary")
                };
                var output = diffCommand.ReadLine();
                FileUtility.Prepare(this.transactionPatchPath);
                File.WriteAllText(this.transactionPatchPath, output);
                this.transactionMessageList.Add(comment);
                this.transactionPropertyList.AddRange(properties);
                return;
            }

            try
            {
                var statusCommand = new GitCommand(this.BasePath, "status")
                {
                    new GitCommandItem('s')
                };
                var items = statusCommand.ReadLines(true);
                if (items.Length != 0)
                {
                    var authorValue = new GitAuthor(author);
                    GitConfig.SetValue(this.BasePath, "user.email", authorValue.Email == string.Empty ? "<>" : authorValue.Email);
                    GitConfig.SetValue(this.BasePath, "user.name", authorValue.Name);

                    var commitCommand = new GitCommitCommand(this.BasePath, author, comment);
                    var result        = commitCommand.Run(this.logService);
                    this.logService?.Debug(result);
                    var log = GitLogInfo.GetLatestLog(this.BasePath);
                    this.repositoryInfo.Revision         = log.CommitID;
                    this.repositoryInfo.ModificationInfo = new SignatureDate(author, log.CommitDate);

                    this.SetNotes(properties);
                    //this.isModified = true;
                    //this.Pull();
                    //this.Push();
                    //this.PushNotes();
                }
                else
                {
                    this.logService?.Debug("repository no changes. \"{0}\"", this.BasePath);
                }
            }
            catch (Exception e)
            {
                this.logService?.Warn(e);
                throw;
            }
        }