Пример #1
0
        public bool Equals(GitCommit commit)
        {
            if (_committer != commit.Committer)
            {
                return(false);
            }

            if (_date.ToString() != commit.Date.ToString())
            {
                return(false);
            }

            if (_message != commit._message)
            {
                return(false);
            }

            if (Branch != commit.Branch)
            {
                return(false);
            }

            if (Url != commit.Url)
            {
                return(false);
            }

            if (_id != commit.Id)
            {
                return(false);
            }

            return(true);
        }
Пример #2
0
        /// <summary>
        /// Returns list of type Commit of all
        /// commits of current user.
        /// </summary>
        /// <returns></returns>
        public List <GitCommit> Commits()
        {
            List <GitCommit> commits = new List <GitCommit>();

            try
            {
                foreach (Commit commit in _repo.Commits)
                {
                    try
                    {
                        if (commit.Author.Name.Contains(AppSettings.Instance.GitUserName))
                        {
                            GitCommit gitCommit = ToGitCommit(commit);
                            gitCommit.Branch = _repo.Head.FriendlyName;
                            commits.Add(gitCommit);
                        }
                    }
                    catch (Exception)
                    {
                        // eat it
                    }
                }
            }
            catch (Exception)
            {
                // eat it
            }

            return(commits);
        }
Пример #3
0
        public GitCommit ToGitCommit(Commit commit)
        {
            GitCommit gitCommit = new GitCommit(commit.Committer.Name, commit.Committer.When.DateTime, commit.Message, commit.Id.ToString())
            {
                Url = _url
            };

            return(gitCommit);
        }
Пример #4
0
 public override void RemoveCommit(GitCommit commit)
 {
     using (MySqlCommand cmd = _connection.CreateCommand())
     {
         cmd.CommandText = $"DELETE FROM `{GitTableName}` WHERE (`Committer` = @Committer AND `Date` = @Date AND `Message` = @Message AND `Branch` = @Branch AND `Url` = @Url AND `Id` = @Id)";
         cmd.Parameters.Add(new MySqlParameter("Committer", commit.Committer));
         cmd.Parameters.Add(new MySqlParameter("Date", DateTimeSqLite(commit.Date)));
         cmd.Parameters.Add(new MySqlParameter("Message", commit.Message));
         cmd.Parameters.Add(new MySqlParameter("Branch", commit.Branch));
         cmd.Parameters.Add(new MySqlParameter("Url", commit.Url));
         cmd.Parameters.Add(new MySqlParameter("Id", commit.Id));
         AddToPump(cmd);
     }
 }
Пример #5
0
 public override void RemoveCommit(GitCommit commit)
 {
     using (SQLiteCommand cmd = _connection.CreateCommand())
     {
         cmd.CommandText = $"DELETE FROM [{GitTableName}] WHERE (Committer = @Committer AND Date = @Date AND Message = @Message AND Branch = @Branch AND Url = @Url AND Id = @Id)";
         cmd.Parameters.Add(new SQLiteParameter("Committer", commit.Committer));
         cmd.Parameters.Add(new SQLiteParameter("Date", DateTimeSqLite(commit.Date)));
         cmd.Parameters.Add(new SQLiteParameter("Message", commit.Message));
         cmd.Parameters.Add(new SQLiteParameter("Branch", commit.Branch));
         cmd.Parameters.Add(new SQLiteParameter("Url", commit.Url));
         cmd.Parameters.Add(new SQLiteParameter("Id", commit.Id));
         cmd.ExecuteNonQuery();
     }
 }
Пример #6
0
 public override void AddCommit(GitCommit commit)
 {
     logger.Info($"Add commit: {commit.Message}");
     using (MySqlCommand cmd = _connection.CreateCommand())
     {
         cmd.CommandText = $"INSERT IGNORE INTO `{GitTableName}` VALUES(@Committer, @Date, @Message, @Branch, @Url, @Id)";
         cmd.Parameters.Add(new MySqlParameter("Committer", commit.Committer));
         cmd.Parameters.Add(new MySqlParameter("Date", DateTimeSqLite(commit.Date)));
         cmd.Parameters.Add(new MySqlParameter("Message", commit.Message));
         cmd.Parameters.Add(new MySqlParameter("Branch", commit.Branch));
         cmd.Parameters.Add(new MySqlParameter("Url", commit.Url));
         cmd.Parameters.Add(new MySqlParameter("Id", commit.Id));
         AddToPump(cmd);
     }
 }
Пример #7
0
 public override void AddCommit(GitCommit commit)
 {
     logger.Info($"Add commit: {commit.Message}");
     using (SQLiteCommand cmd = _connection.CreateCommand())
     {
         cmd.CommandText = $"INSERT OR IGNORE INTO [{GitTableName}] VALUES(@Committer, @Date, @Message, @Branch, @Url, @Id)";
         cmd.Parameters.Add(new SQLiteParameter("Committer", commit.Committer));
         cmd.Parameters.Add(new SQLiteParameter("Date", DateTimeSqLite(commit.Date)));
         cmd.Parameters.Add(new SQLiteParameter("Message", commit.Message));
         cmd.Parameters.Add(new SQLiteParameter("Branch", commit.Branch));
         cmd.Parameters.Add(new SQLiteParameter("Url", commit.Url));
         cmd.Parameters.Add(new SQLiteParameter("Id", commit.Id));
         cmd.ExecuteNonQuery();
     }
 }
Пример #8
0
        public override List <GitCommit> GetCommits()
        {
            logger.Info("Get Commits...........");
            List <GitCommit>  result = new List <GitCommit>();
            string            qry    = $"SELECT * FROM [{GitTableName}]";
            DataTable         vt     = new DataTable();
            SQLiteDataAdapter da     = new SQLiteDataAdapter(qry, _connection);

            da.Fill(vt);

            foreach (DataRow row in vt.Rows)
            {
                GitCommit commit = new GitCommit(row["Committer"].ToString(), Convert.ToDateTime(row["Date"].ToString()), row["Message"].ToString(), row["Id"].ToString())
                {
                    Branch = row["Branch"].ToString(), Url = row["Url"].ToString(),
                };
                result.Add(commit);
            }

            logger.Info("Get Commits...........FINISHED!!!");
            return(result);
        }
Пример #9
0
 public override void RemoveCommit(GitCommit commit)
 {
     throw new NotImplementedException();
 }
Пример #10
0
 public override void RemoveCommit(GitCommit commit)
 {
     _primary.RemoveCommit(commit);
     _secondary?.RemoveCommit(commit);
 }
Пример #11
0
 public override void AddCommit(GitCommit commit)
 {
     _primary.AddCommit(commit);
     _secondary?.AddCommit(commit);
 }
Пример #12
0
 public abstract void RemoveCommit(GitCommit commit);
Пример #13
0
 public abstract void AddCommit(GitCommit commit);