Exemplo n.º 1
0
        /*
         * Convert all the commits in the repository as code history record and add these records
         * to the given code history.
         */
        public void AddCommitsToCodeHistory(ICodeHistory codeHistory)
        {
            // All commits in time order.
            var commits = GetAndOrderAllCommits();

            // Iterate all of the commits.
            for (int i = 0; i < commits.Count(); i ++)
            {
                var commit = commits.ElementAt(i);

                // Get the changes that are changing the C# source code.
                var changes = commit.Changes.Where(c => c.Name.EndsWith(".cs") &&
                        c.ChangedObject.IsBlob);

                // If we found such changes.
                if (changes.Any())
                {
                    // For each change in the found changes.
                    foreach (var change in changes)
                    {
                        // Get the file name of where the change is performed on.
                        string fileName = change.Name;

                        // Get the source after change.
                        string source = ((Blob)change.ChangedObject).Data;

                        // Add the source as a new record to the history.
                        codeHistory.AddRecord(CreateUniqueName(fileName), source);

                        // If we did not meet with the file name, add it to the list.
                        if(!fileNames.Contains(fileName))
                        {
                            fileNames.Add(fileName);
                        }
                    }
                }
                logger.Info("Finish saving " + i + " out of " + commits.Count() + " commits.");
            }
        }
 public SearchRefactoringComponentTests()
 {
     this.history = CodeHistory.GetInstance();
 }
Exemplo n.º 3
0
 /* Get the record heads for this project. */
 public IEnumerable<ICodeHistoryRecord> GetHeadHitoryRecords(ICodeHistory history)
 {
     var records = new List<ICodeHistoryRecord>();
     if (fileNames.Any())
     {
         // For each encountered name in the visiting process.
         foreach (var fileName in fileNames)
         {
             // Get the latest record for the file name.
             var record = history.GetLatestRecord(CreateUniqueName(fileName));
             if (record != null)
             {
                 records.Add(record);
             }
         }
     }
     return records.AsEnumerable();
 }