public string GetEnvFileContent(Models.Repository repo, string personalAccessKey) { var checkOutFolder = GetLocalRepoFolder(repo, personalAccessKey); var envContent = File.ReadAllText(checkOutFolder + "/.env"); return(envContent); }
public string GetDockerComposeFileContent(Models.Repository repo, string personalAccessKey) { var checkOutFolder = GetLocalRepoFolder(repo, personalAccessKey); var dockerComposePath = checkOutFolder + "/docker-compose.yml"; var dockerComposeContent = File.ReadAllText(dockerComposePath); return(dockerComposeContent); }
private string GetLocalFolder(Models.Repository repo) { string appData = Path.Combine(GetFolderPath(SpecialFolder.LocalApplicationData, SpecialFolderOption.DoNotVerify), "ovotrack_git", repo.Project.Key, repo.Slug); if (Directory.Exists(appData) == false) { Directory.CreateDirectory(appData); } return(appData); }
public void WriteEnvFileContent(Models.Repository repo, string fileContent, string personalAccessKey) { var checkOutFolder = GetLocalRepoFolder(repo, personalAccessKey); var dockerComposePath = checkOutFolder + "/.env"; try { File.WriteAllText(dockerComposePath, fileContent); CommitFileToRepo(".env", repo, personalAccessKey); } catch (Exception e) { Console.WriteLine(e); throw; } }
private void CommitFileToRepo(string fileName, Models.Repository repo, string personalAccessKey) { using (var gitRepo = new Repository(GetLocalFolder(repo))) { gitRepo.Index.Add(fileName); gitRepo.Index.Write(); // Create the committer's signature and commit Signature author = new Signature("Webservice", "*****@*****.**", DateTime.Now); Signature committer = author; Commit commit = gitRepo.Commit("Modified " + fileName + " by webservice", author, committer); foreach (var gitRepoBranch in gitRepo.Branches) { gitRepo.Network.Push(gitRepoBranch, getPushOptions(personalAccessKey)); } } }
public Models.Repository GetDeploymentRepo(string repoName, string personalAccessKey) { var repos = GetDeploymentRepos(personalAccessKey); var depRepo = new Models.Repository(); foreach (var repo in repos.Where(repo => repo.Name == repoName)) { depRepo = repo; } if (depRepo.Name.Length != 0) { GetLocalRepoFolder(depRepo, personalAccessKey); return(depRepo); } return(null); }
private string GetLocalRepoFolder(Models.Repository repo, string personalAccessKey) { var checkOutFolder = GetLocalFolder(repo); string logMessage = ""; if (Repository.IsValid(checkOutFolder) == false) { checkOutFolder = Repository.Clone(repo.CloneUrl, checkOutFolder, getCloneOptions(personalAccessKey)); } else { using (var tmpRepo = new Repository(checkOutFolder)) { var remote = tmpRepo.Network.Remotes["origin"]; var refSpecs = remote.FetchRefSpecs.Select(x => x.Specification); Commands.Fetch(tmpRepo, remote.Name, refSpecs, getFetchOptions(personalAccessKey), logMessage); } } return(checkOutFolder); }