Example #1
0
        static void Main(string[] args)
        {
            var project = new GitProject(@"git://github.com/hbons/SparkleShare.git");
            project.Clone();
            var infors = AnalyzeRevisionHistory(project.GetCurrentCommit(), new CommentStrategy());

            var operations = new MySqlOperation();

             //   operations.DropTable();
             //   operations.CreateTable();

            foreach (var infor in infors)
            {
                foreach (var change in infor.GetSourceCodeChangesWithInterestedContent())
                {
                    foreach (var content in change.interestedContents)
                    {
                        operations.InsertRecord(project.GetSourceFolder(), infor.GetCommitDate(),
                            infor.GetAuthorEmail(), infor.GetCommitterEmail(), change.fileName, content);
                    }
                }
            }

            operations.Close();
        }
            public override void Perform()
            {
                try
                {
                    logger.Info("start handling " + gitHttp);

                    // Create a project with the given url.
                    var project = new GitProject(gitHttp);

                    // Clone the project to local.
                    project.Clone();
                    logger.Info("clone finished.");

                    // Add commits to the code history, and get all the heads of this project history.
                    project.AddCommitsToCodeHistory(CodeHistory.GetInstance());
                    var records = project.GetHeadHitoryRecords(CodeHistory.GetInstance());
                    logger.Info("save history record finished. ");

                    // Create a detector, and start detecting from each head.
                    var detector = new RecordRefactoringDetector();

                    // To track the progress.
                    int totalRecordCount = records.Count();
                    int finishedCount = 0;
                    foreach (var record in records)
                    {
                        if (!ExcludeFile(record.GetFile()))
                        {
                            logger.Info("Start refactoring detection for " + record.GetFile() + " in " + gitHttp);
                            logger.Info("Finished count: " + finishedCount +"; Total count: "+ totalRecordCount);
                            detector.DetectRefactorings(record);
                        }
                        finishedCount ++;
                    }
                }catch(Exception e)
                {
                    logger.Fatal(e);
                }
            }