예제 #1
0
        /// <summary>
        ///     Gets checkins history from VCS sinse the last checkin
        /// </summary>
        /// <param name="sinceUtc">The first checkin date</param>
        /// <param name="untilUtc">The last chekin date</param>
        /// <returns>List of checkins sinse the last chekin date</returns>
        public IEnumerable <Commit> GetCommits(DateTime?sinceUtc = null, DateTime?untilUtc = null)
        {
            var tempPath = Path.GetTempPath();

            var guid = Guid.NewGuid().ToString();

            var versionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);

            var folderPath = Path.Combine(tempPath,
                                          versionInfo.CompanyName,
                                          versionInfo.ProductName,
                                          Title,
                                          guid);

            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }

            var repository = new GitRepository(folderPath);

            repository.CloneFrom(new CloneRepository(
                                     GetSetting(GitSettingKeys.Url),
                                     null,
                                     GetSetting(GitSettingKeys.Username),
                                     GetSetting(GitSettingKeys.Password)));

            var branches = GetBranches();

            var commitsList = repository.GetCommits(
                branches.Select(_ => _.Name),
                new GetCommits(sinceUtc, untilUtc));

            DirectoryHelper.SafeDelete(folderPath);

            return(commitsList);
        }