Ejemplo n.º 1
0
        public async Task <Tuple <Repository, string> > AddExistingRepositoryAsync(string path)
        {
            var repository = new Repository();
            var branches   = await _gitService.GetBranchesAsync(path).ConfigureAwait(false);

            var error = await GitParser.ParseError(branches.Error).ConfigureAwait(false);

            if (string.IsNullOrWhiteSpace(error))
            {
                var parseBranches = await GitParser.ParseBranchAsync(branches.Output).ConfigureAwait(false);

                var branchesWithCommit = await GetBranchWithCommitsAsync(path, parseBranches).ConfigureAwait(false);

                var createName = path.Split('\\');
                var name       = createName.Last().Trim();
                var remote     = await _gitService.RemoteAsync(path).ConfigureAwait(false);

                var url = await GitParser.ParseRemoteAsync(remote.Output).ConfigureAwait(false);

                repository = new Repository()
                {
                    Id       = Guid.NewGuid(),
                    Name     = name,
                    Path     = path,
                    Branches = branchesWithCommit,
                    Url      = url
                };
                await _repositoriesService.AddRepositoryAsync(repository).ConfigureAwait(false);

                error = null;
            }
            else
            {
                repository = null;
            }
            var result = Tuple.Create(repository, error);

            return(result);
        }