Exemplo n.º 1
0
        private static void WriteDefaultValuesForEmptyParameters(SyncToolParameters result)
        {
            if (string.IsNullOrEmpty(result.FolderPath))
            {
                return;
            }

            result.ServerUri = @"http://212.143.31.81:8080/tfs";

            if (string.IsNullOrEmpty(result.User) || string.IsNullOrEmpty(result.Password))
            {
                result.User     = @"OLIVESOFT\Automation";
                result.Password = "******";
            }

            if (string.IsNullOrEmpty(result.Comment))
            {
                result.Comment = $"Source Control Update -{Path.GetFileName(result.FolderPath)} - {DateTime.Now.ToString("D", new CultureInfo("en-US"))}";
            }
        }
Exemplo n.º 2
0
        private static SyncToolParameters GetParametersFromArguments(string[] arguments)
        {
            var result = new SyncToolParameters();

            for (int i = 0; i < arguments.Length; i++)
            {
                switch (arguments[i].ToLower())
                {
                case "f":
                    i++;
                    result.FolderPath = arguments[i];
                    break;

                case "u":
                    i++;
                    result.User = arguments[i];

                    if (!result.User.StartsWith("OLIVESOFT"))
                    {
                        result.User = ($"OLIVESOFT\\{result.User}");
                    }

                    break;

                case "p":
                    i++;
                    result.Password = arguments[i];
                    break;

                case "c":
                    i++;
                    result.Comment = arguments[i];
                    break;
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        //static void Main(string[] args) // for tests
        //{
        //    ILogger logger = new ConsoleLogger();
        //    GitSourceControlProvider pro = new GitSourceControlProvider("https://github.com/CagdasTrials/Trials.git", "CagdasTrials","---", logger);
        //    pro.LoadWorkspace(@"D:\GitRepos\RepoX");
        //    pro.DeleteServerItemsWhichHaveNoLocalItems();

        //    string xx = "";
        //}

        static void Main(string[] args)
        {
            var logger = new ConsoleLogger();

            if (args.Length < 1)
            {
                logger.LogError("Invalid arguments - at least path to folder is required");

                return;
            }

            if (args[0] == "?")
            {
                WriteHelpInfo();

                return;
            }

            SyncToolParameters parameters = GetParameters(args);

            if (string.IsNullOrEmpty(parameters.FolderPath))
            {
                logger.LogError("Folder parameter (f) should be specified.");

                return;
            }

            if (Directory.Exists(parameters.FolderPath) == false)
            {
                logger.LogError($"Folder {parameters.FolderPath} does not exist");

                return;
            }

            ISourceControlProvider provider;

            bool useGit = false;

            if (string.IsNullOrEmpty(parameters.SourceControl))
            {
                if (parameters.SourceControl.ToLower() == "git")
                {
                    useGit = true;
                }
            }

            if (useGit)
            {
                try
                {
                    provider = new GitSourceControlProvider(
                        parameters.ServerUri,
                        parameters.User,
                        parameters.Password,
                        logger
                        );
                }
                catch (Exception e)
                {
                    logger.LogError(e.Message);
                    return;
                }
            }
            else
            {
                try
                {
                    provider = new TfsSourceControlProvider(
                        parameters.ServerUri,
                        parameters.User,
                        parameters.Password,
                        logger
                        );
                }
                catch (TeamFoundationServerUnauthorizedException)
                {
                    logger.LogError("Could not connect to Source Control with providere credentials");
                    return;
                }
            }

            var merger = new DifferencesMerger(provider, logger);

            try
            {
                StringBuilder log = new StringBuilder();
                merger.MergeDifferencesInFolder(parameters.FolderPath, parameters.Comment, log);
            }
            catch (Exception ex)
            {
                logger.LogError(ex.Message);
            }
        }