public Task <GitRepo> Add(GitRepoInput gitRepo) { string fullPath = GetRepoPath(gitRepo.Name); if (Directory.Exists(fullPath)) { throw new InvalidOperationException($"A repository named '{gitRepo.Name}' already exists."); } Directory.CreateDirectory(fullPath); var startInfo = new ProcessStartInfo("git", "init --bare"); startInfo.WorkingDirectory = fullPath; var result = processRunner.RunProcessWithOutput(startInfo); if (result != 0) { throw new InvalidOperationException($"Error initializing git repository '{gitRepo.Name}'."); } var dirInfo = new DirectoryInfo(fullPath); return(Task.FromResult(GetGitRepoInfo(dirInfo))); }
public async Task <GitRepo> Add([FromBody] GitRepoInput gitRepo) { return(await repo.Add(gitRepo)); }