Esempio n. 1
0
 internal int GitAddTag(Processor processor, string gitTagName, string gitCommitId, string gitTagComment)
 {
     string[] msg;
     return RunGitCommand(processor.WorkingFolder, processor.GitCmd, string.Format(GIT_ADD_TAG_CMD, gitTagName, gitCommitId, gitTagComment),
         string.Empty,
         out msg);
 }
Esempio n. 2
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        //[STAThread]
        static void Main(string[] args)
        {
            Console.WriteLine("Vault2Git -- converting history from Vault repositories to Git");

            //get configuration for branches
            var paths = ConfigurationManager.AppSettings["Convertor.Paths"];
            var pathPairs = paths.Split(';')
                .ToDictionary(
                pair =>
                    pair.Split('~')[1], pair => pair.Split('~')[0]
                    );

            //parse params
            var param = Params.Parse(args, pathPairs.Keys);

            //get count from param
            if (param.Errors.Count() > 0)
            {
                foreach (var e in param.Errors)
                    Console.WriteLine(e);
                return;
            }

            Console.WriteLine("   use Vault2Git --help to get additional info");

            _useConsole = param.UseConsole;
            _useCapsLock = param.UseCapsLock;
            _ignoreLabels = param.IgnoreLabels;

            var processor = new Vault2Git.Lib.Processor()
                                {
                                    WorkingFolder = ConfigurationManager.AppSettings["Convertor.WorkingFolder"],
                                    GitCmd = ConfigurationManager.AppSettings["Convertor.GitCmd"],
                                    GitDomainName = ConfigurationManager.AppSettings["Git.DomainName"],
                                    VaultServer = ConfigurationManager.AppSettings["Vault.Server"],
                                    VaultRepository = ConfigurationManager.AppSettings["Vault.Repo"],
                                    VaultUser = ConfigurationManager.AppSettings["Vault.User"],
                                    VaultPassword = ConfigurationManager.AppSettings["Vault.Password"],
                                    Progress = ShowProgress,
                                    SkipEmptyCommits = param.SkipEmptyCommits
                                };

            processor.Pull
                (
                    pathPairs.Where(p => param.Branches.Contains(p.Key))
                    , 0 == param.Limit ? 999999999 : param.Limit
                );

            if (!_ignoreLabels)
                processor.CreateTagsFromLabels();

            #if DEBUG
                        Console.WriteLine("Press ENTER");
                        Console.ReadLine();
            #endif
        }
Esempio n. 3
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        //[STAThread]
        static void Main(string[] args)
        {
            string paths = null;
            string workingFolder = null;
            System.Configuration.Configuration configuration = null;

            Console.WriteLine("Vault2Git -- converting history from Vault repositories to Git");
            System.Console.InputEncoding = System.Text.Encoding.UTF8;

            // First look for Config file in the current directory - allows for repository-based config files
            string configPath = System.IO.Path.Combine(Environment.CurrentDirectory, "Vault2Git.exe.config");
            if (File.Exists(configPath))
            {
               System.Configuration.ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap();
               configFileMap.ExeConfigFilename = configPath;

               configuration = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);
            }
            else
            {
               // Get normal exe file config.
               // This is what happens by default when using ConfigurationManager.AppSettings["setting"]
               // to access config properties
            #if DEBUG
               string applicationName = Environment.GetCommandLineArgs()[0];
            #else
               string applicationName = Environment.GetCommandLineArgs()[0]+ ".exe";
            #endif

               configPath = System.IO.Path.Combine(Environment.CurrentDirectory, applicationName);
               configuration = ConfigurationManager.OpenExeConfiguration(configPath);
            }

            // Get access to the AppSettings properties in the chosen config file
            AppSettingsSection appSettings = (AppSettingsSection)configuration.GetSection("appSettings");

            Console.WriteLine("Using config file " + configPath );

            // Get Paths parameter first as its required for validation of branches parameter
            var paramInitial = Params.InitialParse(args);
            paths = paramInitial.Paths;

            if (paths == null)
            {
               //get configuration for branches
               paths = appSettings.Settings["Convertor.Paths"].Value;
            }

            var pathPairs = paths.Split(';')
                .ToDictionary(
                pair =>
                    pair.Split('~')[1], pair => pair.Split('~')[0]
                    );

            //parse rest of params
            var param = Params.Parse(args, pathPairs.Keys);

            //get count from param
            if (param.Errors.Count() > 0)
            {
                foreach (var e in param.Errors)
                    Console.WriteLine(e);
                return;
            }

            Console.WriteLine("   use Vault2Git --help to get additional info");

               _useConsole = param.UseConsole;
            _useCapsLock = param.UseCapsLock;
            _ignoreLabels = param.IgnoreLabels;
            workingFolder = param.Work;

            if (workingFolder == null)
            {
               workingFolder = appSettings.Settings["Convertor.WorkingFolder"].Value;
            }

            // check working folder ends with trailing slash
            if (workingFolder.Last() != '\\')
            {
                workingFolder += '\\';
            }

            if (param.Verbose)
            {
               Console.WriteLine("WorkingFolder = {0}", workingFolder );
               Console.WriteLine("GitCmd = {0}", appSettings.Settings["Convertor.GitCmd"].Value);
               Console.WriteLine("GitDomainName = {0}", appSettings.Settings["Git.DomainName"].Value);
               Console.WriteLine("VaultServer = {0}", appSettings.Settings["Vault.Server"].Value);
               Console.WriteLine("VaultRepository = {0}", appSettings.Settings["Vault.Repo"].Value);
               Console.WriteLine("VaultUser = {0}", appSettings.Settings["Vault.User"].Value );
               Console.WriteLine("VaultPassword = {0}", appSettings.Settings["Vault.Password"].Value);
               Console.WriteLine("Converterpaths = {0}\n", appSettings.Settings["Convertor.Paths"].Value);
            }

            var processor = new Vault2Git.Lib.Processor()
                                {
                                    WorkingFolder = workingFolder,
                                    GitCmd = appSettings.Settings["Convertor.GitCmd"].Value,
                                    GitDomainName = appSettings.Settings["Git.DomainName"].Value,
                                    VaultServer = appSettings.Settings["Vault.Server"].Value,
                                    VaultRepository = appSettings.Settings["Vault.Repo"].Value,
                                    VaultUser = appSettings.Settings["Vault.User"].Value,
                                    VaultPassword = appSettings.Settings["Vault.Password"].Value,
                                    Progress = ShowProgress,
                                    SkipEmptyCommits = param.SkipEmptyCommits,
                                    Verbose = param.Verbose,
                                    Pause = param.Pause,
                                    ForceFullFolderGet= param.ForceFullFolderGet
                                };

            processor.Pull
                (
                    pathPairs.Where(p => param.Branches.Contains(p.Key))
                    , 0 == param.Limit ? 999999999 : param.Limit
                    , 0 == param.RestartLimit ? 20 : param.RestartLimit
                );

            if (!_ignoreLabels)
                processor.CreateTagsFromLabels();

            #if DEBUG
                        Console.WriteLine("Press ENTER");
                        Console.ReadLine();
            #endif
        }
Esempio n. 4
0
 internal int GitLog(Processor processor, string gitBranch, out string[] msg)
 {
     return RunGitCommand(processor.WorkingFolder, processor.GitCmd, string.Format(GIT_LAST_COMMIT_INFO_CMD, gitBranch), string.Empty, out msg);
 }
Esempio n. 5
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        //[STAThread]
        static void Main(string[] args)
        {
            Console.WriteLine("Vault2Git -- converting history from Vault repositories to Git");
            System.Console.InputEncoding = System.Text.Encoding.UTF8;

            //get configuration for branches
            string        paths    = ConfigurationManager.AppSettings["Convertor.Paths"];
            List <string> branches = paths.Split(';').ToList();

            //parse params
            var param = Params.Parse(args, branches);

            //get count from param
            if (param.Errors.Count() > 0)
            {
                foreach (var e in param.Errors)
                {
                    Console.WriteLine(e);
                }
                return;
            }

            Console.WriteLine("   use Vault2Git --help to get additional info");

            _useConsole   = param.UseConsole;
            _useCapsLock  = param.UseCapsLock;
            _ignoreLabels = param.IgnoreLabels;
            _buildGraft   = param.BuildGraft;

            if (string.IsNullOrWhiteSpace(ConfigurationManager.AppSettings["MappingSaveLocation"]))
            {
                Console.Error.WriteLine($"Configuration MappingSaveLocation is not defined into application' settings. Please set a valid value.");
            }

            var processor = new Vault2Git.Lib.Processor()
            {
                WorkingFolder       = ConfigurationManager.AppSettings["Convertor.WorkingFolder"],
                GitCmd              = ConfigurationManager.AppSettings["Convertor.GitCmd"],
                GitDomainName       = ConfigurationManager.AppSettings["Git.DomainName"],
                VaultServer         = ConfigurationManager.AppSettings["Vault.Server"],
                VaultUseSSL         = (ConfigurationManager.AppSettings["Vault.UseSSL"].ToLower() == "true"),
                VaultRepository     = ConfigurationManager.AppSettings["Vault.Repo"],
                VaultUser           = ConfigurationManager.AppSettings["Vault.User"],
                VaultPassword       = ConfigurationManager.AppSettings["Vault.Password"],
                RevisionStartDate   = ConfigurationManager.AppSettings["RevisionStartDate"] ?? "2005-01-01",
                RevisionEndDate     = ConfigurationManager.AppSettings["RevisionEndDate"] ?? "2020-12-31",
                MappingSaveLocation = ConfigurationManager.AppSettings["MappingSaveLocation"],
                AuthorMapPath       = ConfigurationManager.AppSettings["CustomMapPath"] ?? "c:\\temp\\mapfile.xml",
                Progress            = ShowProgress,
                SkipEmptyCommits    = param.SkipEmptyCommits
            };

            if (_buildGraft)
            {
                processor.buildGrafts();
            }
            else
            {
                processor.Pull
                (
                    param.Branches
                    , 0 == param.Limit ? 999999999 : param.Limit
                );

                if (!_ignoreLabels)
                {
                    processor.CreateTagsFromLabels();
                }
            }
#if DEBUG
            Console.WriteLine("Press ENTER");
            Console.ReadLine();
#endif
        }
Esempio n. 6
0
        /// <summary>
        ///     The main entry point for the application.
        /// </summary>
        //[STAThread]
        private static void Main(string[] args)
        {
            try
            {
                _logger.Info("Vault2Git -- converting history from Vault repositories to Git");
                Console.InputEncoding = Encoding.UTF8;

                //get configuration for branches
                var paths = ConfigurationManager.AppSettings["Convertor.Paths"];
                var pathPairs = paths.Split(';')
                                     .ToDictionary(
                                         pair =>
                                             pair.Split('~')[1], pair => pair.Split('~')[0]
                    );

                //parse params
                var param = Params.Parse(args, pathPairs.Keys);

                //get count from param
                if (param.Errors.Any())
                {
                    foreach (var e in param.Errors)
                        _logger.Error(e);
                    return;
                }

                _logger.Info("   use Vault2Git --help to get additional info");

                _useConsole = param.UseConsole;
                _useCapsLock = param.UseCapsLock;
                _ignoreLabels = param.IgnoreLabels;

                _logger.Debug("initialising processor.");
                var processor = new Processor
                                {
                                    WorkingFolder = ConfigurationManager.AppSettings["Convertor.WorkingFolder"],
                                    GitCmd = ConfigurationManager.AppSettings["Convertor.GitCmd"],
                                    GitDomainName = ConfigurationManager.AppSettings["Git.DomainName"],
                                    VaultServer = ConfigurationManager.AppSettings["Vault.Server"],
                                    VaultRepository = ConfigurationManager.AppSettings["Vault.Repo"],
                                    VaultUser = ConfigurationManager.AppSettings["Vault.User"],
                                    VaultPassword = ConfigurationManager.AppSettings["Vault.Password"],
                                    Progress = ShowProgress,
                                    SkipEmptyCommits = param.SkipEmptyCommits
                                };

                _logger.Debug("pulling request");
                processor.Pull
                    (
                        pathPairs.Where(p => param.Branches.Contains(p.Key))
                        , 0 == param.Limit ? 999999999 : param.Limit
                    );

                if (!_ignoreLabels)
                {
                    _logger.Debug("creating tags from labels");
                    processor.CreateTagsFromLabels();
                }

                _logger.Info("Vault2Git life ended. Game over.");
            }
            catch (Exception exception)
            {
                _logger.Error(string.Format("Exception occurred in main program. Exception : {0}\nStackTrace: {1}",
                    exception.GetBaseException().Message, exception.StackTrace));
            }
        }
Esempio n. 7
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        //[STAThread]
        static void Main(string[] args)
        {
            string paths         = null;
            string workingFolder = null;

            System.Configuration.Configuration configuration = null;

            Console.WriteLine("Vault2Git -- converting history from Vault repositories to Git");
            System.Console.InputEncoding = System.Text.Encoding.UTF8;

            // First look for Config file in the current directory - allows for repository-based config files
            string configPath = System.IO.Path.Combine(Environment.CurrentDirectory, "Vault2Git.exe.config");

            if (File.Exists(configPath))
            {
                System.Configuration.ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap();
                configFileMap.ExeConfigFilename = configPath;

                configuration = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);
            }
            else
            {
                // Get normal exe file config.
                // This is what happens by default when using ConfigurationManager.AppSettings["setting"]
                // to access config properties
            #if DEBUG
                string applicationName = Environment.GetCommandLineArgs()[0];
            #else
                string applicationName = Environment.GetCommandLineArgs()[0] + ".exe";
            #endif

                configPath    = System.IO.Path.Combine(Environment.CurrentDirectory, applicationName);
                configuration = ConfigurationManager.OpenExeConfiguration(configPath);
            }

            // Get access to the AppSettings properties in the chosen config file
            AppSettingsSection appSettings = (AppSettingsSection)configuration.GetSection("appSettings");

            Console.WriteLine("Using config file " + configPath);

            // Get Paths parameter first as its required for validation of branches parameter
            var paramInitial = Params.InitialParse(args);
            paths = paramInitial.Paths;

            if (paths == null)
            {
                //get configuration for branches
                paths = appSettings.Settings["Convertor.Paths"].Value;
            }

            var pathPairs = paths.Split(';')
                            .ToDictionary(
                pair =>
                pair.Split('~')[1], pair => pair.Split('~')[0]
                );

            //parse rest of params
            var param = Params.Parse(args, pathPairs.Keys);

            //get count from param
            if (param.Errors.Count() > 0)
            {
                foreach (var e in param.Errors)
                {
                    Console.WriteLine(e);
                }
                return;
            }

            Console.WriteLine("   use Vault2Git --help to get additional info");

            _useConsole   = param.UseConsole;
            _useCapsLock  = param.UseCapsLock;
            _ignoreLabels = param.IgnoreLabels;
            workingFolder = param.Work;

            if (workingFolder == null)
            {
                workingFolder = appSettings.Settings["Convertor.WorkingFolder"].Value;
            }

            if (param.Verbose)
            {
                Console.WriteLine("WorkingFolder = {0}", workingFolder);
                Console.WriteLine("GitCmd = {0}", appSettings.Settings["Convertor.GitCmd"].Value);
                Console.WriteLine("GitDomainName = {0}", appSettings.Settings["Git.DomainName"].Value);
                Console.WriteLine("VaultServer = {0}", appSettings.Settings["Vault.Server"].Value);
                Console.WriteLine("VaultRepository = {0}", appSettings.Settings["Vault.Repo"].Value);
                Console.WriteLine("VaultUser = {0}", appSettings.Settings["Vault.User"].Value);
                Console.WriteLine("VaultPassword = {0}", appSettings.Settings["Vault.Password"].Value);
                Console.WriteLine("Converterpaths = {0}\n", appSettings.Settings["Convertor.Paths"].Value);
            }

            var processor = new Vault2Git.Lib.Processor()
            {
                WorkingFolder      = workingFolder,
                GitCmd             = appSettings.Settings["Convertor.GitCmd"].Value,
                GitDomainName      = appSettings.Settings["Git.DomainName"].Value,
                VaultServer        = appSettings.Settings["Vault.Server"].Value,
                VaultRepository    = appSettings.Settings["Vault.Repo"].Value,
                VaultUser          = appSettings.Settings["Vault.User"].Value,
                VaultPassword      = appSettings.Settings["Vault.Password"].Value,
                Progress           = ShowProgress,
                SkipEmptyCommits   = param.SkipEmptyCommits,
                Verbose            = param.Verbose,
                Pause              = param.Pause,
                ForceFullFolderGet = param.ForceFullFolderGet
            };


            processor.Pull
            (
                pathPairs.Where(p => param.Branches.Contains(p.Key))
                , 0 == param.Limit ? 999999999 : param.Limit
                , 0 == param.RestartLimit ? 20 : param.RestartLimit
            );

            if (!_ignoreLabels)
            {
                processor.CreateTagsFromLabels();
            }

#if DEBUG
            Console.WriteLine("Press ENTER");
            Console.ReadLine();
#endif
        }
Esempio n. 8
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        //[STAThread]
        static void Main(string[] args)
        {
            Console.WriteLine("Vault2Git -- converting history from Vault repositories to Git");

            //get configuration for branches
            var paths     = ConfigurationManager.AppSettings["Convertor.Paths"];
            var pathPairs = paths.Split(';')
                            .ToDictionary(
                pair =>
                pair.Split('~')[1], pair => pair.Split('~')[0]
                );

            //parse params
            var param = Params.Parse(args, pathPairs.Keys);

            //get count from param
            if (param.Errors.Count() > 0)
            {
                foreach (var e in param.Errors)
                {
                    Console.WriteLine(e);
                }
                return;
            }

            Console.WriteLine("   use Vault2Git --help to get additional info");

            _useConsole   = param.UseConsole;
            _useCapsLock  = param.UseCapsLock;
            _ignoreLabels = param.IgnoreLabels;

            var processor = new Vault2Git.Lib.Processor()
            {
                WorkingFolder    = ConfigurationManager.AppSettings["Convertor.WorkingFolder"],
                GitCmd           = ConfigurationManager.AppSettings["Convertor.GitCmd"],
                GitDomainName    = ConfigurationManager.AppSettings["Git.DomainName"],
                VaultServer      = ConfigurationManager.AppSettings["Vault.Server"],
                VaultRepository  = ConfigurationManager.AppSettings["Vault.Repo"],
                VaultUser        = ConfigurationManager.AppSettings["Vault.User"],
                VaultPassword    = ConfigurationManager.AppSettings["Vault.Password"],
                Progress         = ShowProgress,
                SkipEmptyCommits = param.SkipEmptyCommits
            };


            processor.Pull
            (
                pathPairs.Where(p => param.Branches.Contains(p.Key))
                , 0 == param.Limit ? 999999999 : param.Limit
            );

            if (!_ignoreLabels)
            {
                processor.CreateTagsFromLabels();
            }

#if DEBUG
            Console.WriteLine("Press ENTER");
            Console.ReadLine();
#endif
        }