Esempio n. 1
0
        public string Clone(GitConfigurationSource source)
        {
            var cloneOptions = new Models.CloneOptions();

            if (source.CloneOptions == null)
            {
                throw new ArgumentNullException($"Required action ${nameof(cloneOptions)}");
            }

            source.CloneOptions(cloneOptions);

            var repoPath = Repository.Clone(
                source.Url,
                Path.Combine(Environment.ExpandEnvironmentVariables(@"/tmp/Confy_" + Guid.NewGuid())),
                new CloneOptions()
            {
                BranchName          = source.Branch,
                CredentialsProvider = (url, fromUrl, types) => new UsernamePasswordCredentials()
                {
                    Username = source.UserNameEnvironmentVariableName,
                    Password = source.AuthTokenEnvironmentVariableName
                }
            });

            if (repoPath.EndsWith(@".git/"))
            {
                repoPath = repoPath.Replace(@".git/", string.Empty);
            }
            return(repoPath);
        }
Esempio n. 2
0
        public string Clone(GitConfigurationSource source)
        {
            var cloneOptions = new Models.CloneOptions();

            if (source.CloneOptions == null)
            {
                throw new ArgumentNullException($"Required action ${nameof(cloneOptions)}");
            }

            source.CloneOptions(cloneOptions);

            var dirPath = Environment.ExpandEnvironmentVariables(@"%userprofile%\AppData\Local\Temp\Confy");

            dirPath = !string.IsNullOrEmpty(cloneOptions.CloneSubDir)
                ? dirPath + $"\\{cloneOptions.CloneSubDir}"
                : dirPath;

            var repoPath = "";

            if (cloneOptions.AlwaysCloneOnStart)
            {
                repoPath = _operations.Clone(source, dirPath + Guid.NewGuid());
            }

            else if (cloneOptions.AlwaysCloneOnStart is false)
            {
                var subDir = string.IsNullOrEmpty(cloneOptions.CloneSubDir)
                    ? throw new ArgumentNullException($"Missing parameter {nameof(cloneOptions.CloneSubDir)}")
                    : cloneOptions.CloneSubDir;

                var directory = Directory
                                .GetDirectories(dirPath.Replace(cloneOptions.CloneSubDir, "")).FirstOrDefault(p => p.Contains(cloneOptions.CloneSubDir));

                if (string.IsNullOrEmpty(directory))
                {
                    repoPath = _operations.Clone(source, dirPath + Guid.NewGuid());
                }
                else
                {
                    repoPath = directory;
                }
            }


            if (repoPath.EndsWith(@".git\"))
            {
                repoPath = repoPath.Replace(@".git\", string.Empty);
            }

            return(repoPath);
        }
Esempio n. 3
0
 internal string Clone(GitConfigurationSource source, string dirPath)
 {
     return(Repository.Clone(
                source.Url,
                Path.Combine(
                    Environment.ExpandEnvironmentVariables(dirPath)),
                new CloneOptions()
     {
         BranchName = source.Branch,
         CredentialsProvider = (url, fromUrl, types) => new UsernamePasswordCredentials()
         {
             Username = source.UserNameEnvironmentVariableName,
             Password = source.AuthTokenEnvironmentVariableName
         }
     }));
 }
Esempio n. 4
0
 public GitConfigurationProvider(GitConfigurationSource source, IPlatformRepository platformRepository)
 {
     _source             = source;
     _platformRepository = platformRepository;
 }