示例#1
0
        public GitPath(IGitSourceControlProvider provider, string sourcePath)
        {
            if (provider == null) throw new ArgumentNullException("provider");
            if (string.IsNullOrEmpty(sourcePath)) return;

            // pathParts => [repoName][repoPath]
            var pathParts = (sourcePath ?? "").Split(new[] { GitPath.RepositorySeparatorChar }, 2);
            if (pathParts.Length != 2) pathParts = new[] { pathParts[0], "" };

            this.Repository = provider.Repositories.SingleOrDefault(repo => repo.RepositoryName == pathParts[0]);

            // now split out the branch
            var relativePathParts = pathParts[1].Split(new[] { GitPath.BranchSeparatorChar }, 2);
            if (relativePathParts.Length == 2)
            {
                this.PathSpecifiedBranch = relativePathParts[0];
                this.RelativePath = relativePathParts[1];
            }
            else
            {
                this.RelativePath = pathParts[1];
            }

            var agent = provider.Agent;
            this.PathOnDisk = agent.CombinePath(this.Repository.GetFullRepositoryPath(agent), this.RelativePath);

            this.Branch = this.PathSpecifiedBranch;
            if (string.IsNullOrEmpty(this.Branch))
                this.Branch = "master";
        }
示例#2
0
        public GitPath(IGitSourceControlProvider provider, string sourcePath)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }
            if (string.IsNullOrEmpty(sourcePath))
            {
                return;
            }

            var match = GitPathRegex.Match(sourcePath);

            if (!match.Success)
            {
                throw new ArgumentException("Invalid source path (missing repository name).");
            }

            var            repositoryName = match.Groups[1].Value;
            var            branchName     = match.Groups[2].Value;
            var            repositoryPath = (match.Groups[3].Value ?? string.Empty).TrimStart('/');
            IGitRepository repository;

            if (string.IsNullOrEmpty(branchName))
            {
                branchName = "master";
            }
            else
            {
                this.PathSpecifiedBranch = branchName;
            }

            if (!string.IsNullOrEmpty(repositoryName))
            {
                repository = provider.Repositories.FirstOrDefault(r => r.RepositoryName == repositoryName);
                if (repository == null)
                {
                    throw new ArgumentException("Invalid repository: " + repositoryName);
                }
            }
            else
            {
                repository = provider.Repositories.FirstOrDefault();
                if (repository == null)
                {
                    throw new InvalidOperationException("No repositories are defined in this provider.");
                }
            }

            this.Branch       = branchName;
            this.Repository   = repository;
            this.RelativePath = repositoryPath;
            this.PathOnDisk   = provider.Agent.CombinePath(repository.GetFullRepositoryPath(provider.Agent), repositoryPath);
        }
 public GitSourceControlProviderCommon(IGitSourceControlProvider ownerProvider, string gitExePath)
 {
     this.owner = ownerProvider;
     this.gitClient = new Lazy<GitClientBase>(
         () =>
         {
             if (string.IsNullOrEmpty(gitExePath))
                 return new LilGitClient(this);
             else
                 return new StandardGitClient(this, gitExePath);
         }
     );
 }
 public GitSourceControlProviderCommon(IGitSourceControlProvider ownerProvider, string gitExePath)
 {
     this.owner     = ownerProvider;
     this.gitClient = new Lazy <GitClientBase>(
         () =>
     {
         if (string.IsNullOrEmpty(gitExePath))
         {
             return(new LilGitClient(this));
         }
         else
         {
             return(new StandardGitClient(this, gitExePath));
         }
     }
         );
 }
示例#5
0
        public GitPath(IGitSourceControlProvider provider, string sourcePath)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }
            if (string.IsNullOrEmpty(sourcePath))
            {
                return;
            }

            // pathParts => [repoName][repoPath]
            var pathParts = (sourcePath ?? "").Split(new[] { GitPath.RepositorySeparatorChar }, 2);

            if (pathParts.Length != 2)
            {
                pathParts = new[] { pathParts[0], "" }
            }
            ;

            this.Repository = provider.Repositories.SingleOrDefault(repo => repo.RepositoryName == pathParts[0]);

            // now split out the branch
            var relativePathParts = pathParts[1].Split(new[] { GitPath.BranchSeparatorChar }, 2);

            if (relativePathParts.Length == 2)
            {
                this.PathSpecifiedBranch = relativePathParts[0];
                this.RelativePath        = relativePathParts[1];
            }
            else
            {
                this.RelativePath = pathParts[1];
            }

            var agent = provider.Agent;

            this.PathOnDisk = agent.CombinePath(this.Repository.GetFullRepositoryPath(agent), this.RelativePath);

            this.Branch = this.PathSpecifiedBranch;
            if (string.IsNullOrEmpty(this.Branch))
            {
                this.Branch = "master";
            }
        }
示例#6
0
        public GitPath(IGitSourceControlProvider provider, string sourcePath)
        {
            if (provider == null)
                throw new ArgumentNullException("provider");
            if (string.IsNullOrEmpty(sourcePath))
                return;

            var match = GitPathRegex.Match(sourcePath);
            if (!match.Success)
                throw new ArgumentException("Invalid source path (missing repository name).");

            var repositoryName = match.Groups[1].Value;
            var branchName = match.Groups[2].Value;
            var repositoryPath = (match.Groups[3].Value ?? string.Empty).TrimStart('/');
            SourceRepository repository;

            if (string.IsNullOrEmpty(branchName))
                branchName = "master";
            else
                this.PathSpecifiedBranch = branchName;

            if (!string.IsNullOrEmpty(repositoryName))
            {
                repository = provider.Repositories.FirstOrDefault(r => r.Name == repositoryName);
                if (repository == null)
                    throw new ArgumentException("Invalid repository: " + repositoryName);
            }
            else
            {
                repository = provider.Repositories.FirstOrDefault();
                if (repository == null)
                    throw new InvalidOperationException("No repositories are defined in this provider.");
            }

            this.Branch = branchName;
            this.Repository = repository;
            this.RepositoryRelativePath = repositoryPath;
            this.WorkspaceDiskPath = provider.Agent.CombinePath(repository.GetDiskPath(provider.Agent), repositoryPath);
        }
示例#7
0
 public StandardGitClient(IGitSourceControlProvider provider, string gitExePath)
     : base(provider)
 {
     this.gitExePath = gitExePath;
 }
示例#8
0
 protected GitClientBase(IGitSourceControlProvider provider)
 {
     this.Provider = provider;
 }
示例#9
0
 public StandardGitClient(IGitSourceControlProvider provider, string gitExePath)
     : base(provider)
 {
     this.gitExePath = gitExePath;
 }
示例#10
0
 public LilGitClient(IGitSourceControlProvider provider)
     : base(provider)
 {
 }
示例#11
0
 public LilGitClient(IGitSourceControlProvider provider)
     : base(provider)
 {
 }
示例#12
0
 protected GitClientBase(IGitSourceControlProvider provider)
 {
     this.Provider = provider;
 }