Ejemplo n.º 1
0
        public static void ResetTag(string tag, PathConstruction.AbsolutePath projectPath, string repositoryUrl,
                                    CredentialsHandler credentialsHandler = null)
        {
            var repository = GitRepositoryBuilder.GetRepository(repositoryUrl, projectPath, credentialsHandler);

            if (repository.Tags.Any(s => string.Equals(s.FriendlyName, tag, StringComparison.OrdinalIgnoreCase)))
            {
                DeleteTag(tag, projectPath, repositoryUrl, credentialsHandler);
            }

            CreateTag(tag, projectPath, repositoryUrl, credentialsHandler);
        }
        internal static void TeamcityDiffFromBaseline(PathConstruction.AbsolutePath projectPath, string baselineName, string branchName, Action <TreeChanges> diffAction, CredentialsHandler credentialsHandler)
        {
            if (TeamCity.Instance == null)
            {
                throw new NoTeamcityInstanceException("No teamcity instance detected");
            }

            var repositoryUrl = TeamCity.Instance.ConfigurationProperties[TeamcityConstants.VcsRootUrl];

            Logger.Info($"Starting rebuilding repository {repositoryUrl}");
            var repository = GitRepositoryBuilder.GetRepository(repositoryUrl, projectPath, credentialsHandler);

            Logger.Info($"Finished rebuilding repository {repositoryUrl}");

            DiffFromBaselineInternal(repository, diffAction, baselineName, branchName);
        }
Ejemplo n.º 3
0
        public static void DeleteTag(string tag, PathConstruction.AbsolutePath projectPath, string repositoryUrl, CredentialsHandler credentialsHandler = null)
        {
            try
            {
                var repository = GitRepositoryBuilder.GetRepository(repositoryUrl, projectPath, credentialsHandler);
                var origin     = repository.Network.Remotes[GitConstants.Origin];

                Logger.Info($"Removing tag {tag}");
                repository.Tags.Remove(tag);
                repository.Network.Push(origin, GitConstants.DeleteRef + GitConstants.RefsTags + tag, new PushOptions {
                    CredentialsProvider = credentialsHandler
                });
                Logger.Info($"Removed tag {tag} from remote");
            }
            catch (Exception)
            {
                Logger.Info($"Failed to removed tag {tag} from remote");
            }
        }
Ejemplo n.º 4
0
        public static void CreateTag(string tag, PathConstruction.AbsolutePath projectPath, string repositoryUrl, CredentialsHandler credentialsHandler = null)
        {
            try
            {
                var repository    = GitRepositoryBuilder.GetRepository(repositoryUrl, projectPath, credentialsHandler);
                var origin        = repository.Network.Remotes[GitConstants.Origin];
                var lastestCommit = repository.Head.Commits.First();

                Logger.Info($"Creating tag {tag} with commit {lastestCommit.Sha}");
                repository.ApplyTag(tag);
                repository.Network.Push(origin, GitConstants.RefsTags + tag, new PushOptions {
                    CredentialsProvider = credentialsHandler
                });
                Logger.Info($"Created tag {tag} with commit {lastestCommit.Sha} on remote");
            }
            catch (Exception)
            {
                Logger.Error($"Failed to create tag {tag} on remote");
            }
        }