Exemplo n.º 1
0
        public void DeleteRepository(string author, string basePath, string repositoryName, string comment, params LogPropertyInfo[] properties)
        {
            var baseUri          = new Uri(basePath);
            var repositoryPath   = baseUri.LocalPath;
            var branchName       = repositoryName;
            var branchCollection = GitBranchCollection.Run(repositoryPath);

            if (branchCollection.Count <= 1)
            {
                throw new InvalidOperationException();
            }

            if (branchCollection.CurrentBranch == branchName)
            {
                var nextBranchName = branchCollection.First(item => item != branchCollection.CurrentBranch);
                this.CheckoutBranch(repositoryPath, nextBranchName);
            }

            var deleteCommand = new GitCommand(repositoryPath, "branch")
            {
                new GitCommandItem('D'),
                branchName
            };

            deleteCommand.Run();
            this.UnsetID(repositoryPath, repositoryName);
        }
Exemplo n.º 2
0
        public string Migrate(string sourcePath)
        {
            var repositoryPath2 = PathUtility.GetTempPath(false);
            var repositoryUri   = new Uri(sourcePath).ToString();

            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                repositoryUri = Regex.Replace(repositoryUri, "(file:///\\w):(.+)", "$1$2");
            }

            var cloneCommand = new GitCommand(null, "svn clone")
            {
                (GitPath)repositoryUri,
                (GitPath)repositoryPath2,
                new GitCommandItem('T', "trunk"),
                new GitCommandItem('b', "branches"),
                new GitCommandItem('b', "tags")
            };

            cloneCommand.OutputDataReceived += (s, e) => Console.WriteLine(e.Data);
            cloneCommand.Run();

            var remoteBranches = GitBranchCollection.GetRemoteBranches(repositoryPath2);
            var branches       = GitBranchCollection.Run(repositoryPath2);

            foreach (var item in remoteBranches)
            {
                if (item != "trunk" && branches.Contains(item) == false)
                {
                    var checkoutCommand = new GitCommand(repositoryPath2, "checkout")
                    {
                        new GitCommandItem('b'),
                        item,
                        $"remotes/origin/{item}"
                    };
                    checkoutCommand.Run();
                }
            }

            var configCommand = new GitCommand(repositoryPath2, "config")
            {
                "receive.denyCurrentBranch",
                "ignore"
            };

            configCommand.Run();
            return(repositoryPath2);
        }