Esempio n. 1
0
        public override async Task ExecuteAsync(string key, string phrase)
        {
            var gitRepoPath = await GitCommandTools.GetSelectedPathAsync(_repositoryBusiness, _talkAgent, _settingAgent);

            if (gitRepoPath == null)
            {
                return;
            }

            var before = _gitBusiness.Shell("status .", gitRepoPath).ToArray();

            var response = _gitBusiness.Shell("reset HEAD .", gitRepoPath).ToArray();

            if (!before.Last().Contains("files have changes"))
            {
                foreach (var line in response)
                {
                    await _talkAgent.SayAsync(line);
                }
            }
            else
            {
                await _talkAgent.SayAsync("There are no staged files.");
            }
        }
Esempio n. 2
0
        public override async Task ExecuteAsync(string key, string phrase)
        {
            var gitRepoPath = await GitCommandTools.GetSelectedPathAsync(_repositoryBusiness, _talkAgent, _settingAgent);

            if (gitRepoPath == null)
            {
                return;
            }

            await _talkAgent.SayAsync("Starting to pull.");

            var response = _gitBusiness.Shell("pull", gitRepoPath).ToArray();

            if (!response.Any())
            {
                await _talkAgent.SayAsync("There is nothing to pull from origin. Everything is up-to-date.");
            }
            else
            {
                foreach (var line in response)
                {
                    await _talkAgent.SayAsync(line);
                }
            }
        }
Esempio n. 3
0
        public override async Task ExecuteAsync(string key, string phrase)
        {
            var gitRepoPath = await GitCommandTools.GetSelectedPathAsync(_repositoryBusiness, _talkAgent, _settingAgent);

            if (gitRepoPath == null)
            {
                return;
            }

            await _talkAgent.SayAsync("Starting to push.");

            var retry = true;

            while (retry)
            {
                retry = false;

                var response = _gitBusiness.Shell("push", gitRepoPath).ToArray();
                if (response.First().Contains("warning: push.default is unset"))
                {
                    //Set push mode to simple
                    var isSetToSimple = await _questionAgent.AskYesNoAsync("The push behaviour has not been set. Is it allright if I set it to simple?");

                    if (isSetToSimple)
                    {
                        var response2 = _gitBusiness.Shell("config --global push.default simple", gitRepoPath).ToArray();
                        foreach (var line in response2)
                        {
                            await _talkAgent.SayAsync(line);
                        }

                        retry = true;
                    }
                }
                else
                {
                    foreach (var line in response)
                    {
                        await _talkAgent.SayAsync(line);
                    }
                }
            }
        }
Esempio n. 4
0
        public override async Task ExecuteAsync(string key, string phrase)
        {
            var gitRepoPath = await GitCommandTools.GetSelectedPathAsync(_repositoryBusiness, _talkAgent, _settingAgent);

            if (gitRepoPath == null)
            {
                return;
            }

            var before   = _gitBusiness.Shell("status .", gitRepoPath).ToArray();
            var response = _gitBusiness.Shell("add .", gitRepoPath).ToArray();

            if (before.Last().Contains("files have changes"))
            {
                await _talkAgent.SayAsync(string.Format("{0} files have been staged.", before.Last().Split(' ')[0]));
            }
            else
            {
                await _talkAgent.SayAsync("There are no changes to stage.");
            }
        }
Esempio n. 5
0
        public override async Task ExecuteAsync(string key, string phrase)
        {
            var gitRepoPath = await GitCommandTools.GetSelectedPathAsync(_repositoryBusiness, _talkAgent, _settingAgent);

            if (gitRepoPath == null)
            {
                return;
            }

            var response = _gitBusiness.Shell("status", gitRepoPath);

            foreach (var line in response)
            {
                await _talkAgent.SayAsync(line);
            }
        }
Esempio n. 6
0
        public override async Task ExecuteAsync(string key, string phrase)
        {
            var gitRepoPath = await GitCommandTools.GetSelectedPathAsync(_repositoryBusiness, _talkAgent, _settingAgent);

            if (gitRepoPath == null)
            {
                return;
            }

            if (await _questionAgent.AskYesNoAsync("Are you sure you want to reset all changes?"))
            {
                var response = _gitBusiness.Shell("reset --hard", gitRepoPath).ToArray();
                foreach (var line in response)
                {
                    await _talkAgent.SayAsync(line);
                }
            }
            else
            {
                await _talkAgent.SayAsync("All your files have been left untouched.");
            }
        }
Esempio n. 7
0
        public override async Task ExecuteAsync(string key, string phrase)
        {
            var gitRepoPath = await GitCommandTools.GetSelectedPathAsync(_repositoryBusiness, _talkAgent, _settingAgent);

            if (gitRepoPath == null)
            {
                return;
            }

            var statusResponse = _gitBusiness.Shell("status", gitRepoPath).ToArray();

            if (!statusResponse.Any(x => x.Contains("are to be committed") || x.Contains("have changes")))
            {
                await _talkAgent.SayAsync("There are no changes to commit.");

                return;
            }

            var    extraFlag     = string.Empty;
            string commitMessage = null;

            if (phrase.Contains("stage"))
            {
                extraFlag += " -a";
            }

            if (phrase.Contains("amend"))
            {
                extraFlag    += " --amend";
                commitMessage = "--no-edit";
            }

            if (string.IsNullOrEmpty(commitMessage))
            {
                commitMessage = "-m \"" + await _questionAgent.AskStringAsync("Enter a commit message") + "\"";
            }

            var retry = true;

            while (retry)
            {
                retry = false;

                var response = _gitBusiness.Shell("commit " + commitMessage + extraFlag, gitRepoPath).ToArray();
                if (response.Any(x => x.Contains("no changes added to commit")))
                {
                    var stage = await _questionAgent.AskYesNoAsync("No files has been staged yet. Do you want to stage all changes and commit all that?");

                    if (stage)
                    {
                        var stageResponse = _gitBusiness.Shell("add .", gitRepoPath).ToArray();
                        retry = true;
                    }
                    else
                    {
                        await _talkAgent.SayAsync("Allright.");
                    }
                }
                else
                {
                    foreach (var line in response)
                    {
                        await _talkAgent.SayAsync(line);
                    }
                }
            }
        }