Пример #1
0
        private LocalChangesAction DefineLocalChangesPolicy(GitRepository repo, string localSha, string remoteSha)
        {
            if (userLocalChangesPolicy == LocalChangesPolicy.Reset && localSha != remoteSha)
            {
                return(LocalChangesAction.Reset);
            }

            if (!repo.HasLocalChanges())
            {
                return(LocalChangesAction.Nothing);
            }
            ConsoleWriter.WriteWarning($"Local changes found in '{repo.RepoPath}'\n{repo.ShowLocalChanges()}");
            switch (userLocalChangesPolicy)
            {
            case LocalChangesPolicy.FailOnLocalChanges:
                throw new GitLocalChangesException("Failed to update " + repo.RepoPath + " due to local changes.");

            case LocalChangesPolicy.ForceLocal:
                return(LocalChangesAction.ForceLocal);

            case LocalChangesPolicy.Pull:
                return(LocalChangesAction.Pull);

            case LocalChangesPolicy.Reset:
                return(LocalChangesAction.Reset);

            case LocalChangesPolicy.Interactive:
                Console.WriteLine("What do you want to do? enter 'f' for saving local changes / 'r' for resetting local changes(git clean & git reset) / 'p' for pull anyway :\n");
                return(GetUserAnswer());
            }
            return(LocalChangesAction.Nothing);
        }