Esempio n. 1
0
        /// <inheritdoc />
        public async Task <IList <GitBranch> > GetRemoteBranches(CancellationToken token)
        {
            GitCommandResponse result = await this.gitProcessManager.RunGit("branch -r", token);

            IList <GitBranch> branches = new List <GitBranch>();

            if (result.Success == false)
            {
                return(branches);
            }

            string[] array = result.ProcessOutput.ToArrayOfLines();
            foreach (string line in array)
            {
                int    arrowPos = line.IndexOf(" -> ", StringComparison.InvariantCulture);
                string branch   = line;
                if (arrowPos != -1)
                {
                    branch = line.Substring(0, arrowPos);
                }

                branches.Add(new GitBranch(branch.Trim(), true));
            }

            return(branches);
        }
Esempio n. 2
0
        /// <inheritdoc />
        public async Task <bool> IsMergeConflict(CancellationToken token)
        {
            GitCommandResponse result = await this.gitProcessManager.RunGit("ls-files -u", token);

            if (result.Success)
            {
                return(false);
            }

            string[] array = result.ProcessOutput.ToArrayOfLines();

            return(array.Length > 0);
        }
Esempio n. 3
0
        /// <inheritdoc />
        public async Task <GitBranch> GetCurrentCheckedOutBranch(CancellationToken token)
        {
            GitCommandResponse result = await this.gitProcessManager.RunGit("branch", token);

            if (!result.Success)
            {
                return(null);
            }

            string[] array = result.ProcessOutput.ToArrayOfLines();
            foreach (string line in array)
            {
                if (line.StartsWith("*"))
                {
                    return(new GitBranch(line.Substring(2), false));
                }
            }

            return(null);
        }
Esempio n. 4
0
        /// <inheritdoc />
        public async Task <IList <GitBranch> > GetLocalBranches(CancellationToken token)
        {
            GitCommandResponse result = await this.gitProcessManager.RunGit("branch", token);

            IList <GitBranch> branches = new List <GitBranch>();

            if (!result.Success)
            {
                return(branches);
            }

            string[] array = result.ProcessOutput.ToArrayOfLines();
            foreach (string line in array)
            {
                string branch = line.Substring(2);
                branches.Add(new GitBranch(branch, false));
            }

            return(branches);
        }