Example #1
0
        public async Task Clone(string projectId, string url, int authorId)
        {
            string tempFolder = Path.Combine(Directory.GetCurrentDirectory(), "..\\GitTemp", Guid.NewGuid().ToString());

            if (!Directory.Exists(tempFolder + "\\ProjectFolder"))
            {
                Directory.CreateDirectory(tempFolder + "\\ProjectFolder");
            }

            try
            {
                await _projectStructureService.RemoveFilesBeforeCloneAsync(Convert.ToInt32(projectId));

                _gitRepository.CloneRepository(url, tempFolder + "\\ProjectFolder\\");
                _gitRepository.StashUntracked(tempFolder + "\\ProjectFolder");

                await ReturnGitToBlob(tempFolder, projectId);

                //_projectStructureService.DeleteTempFolder(tempFolder + "\\ProjectFolder\\.git");
                File.Delete(tempFolder + $"\\ProjectFolder\\g{projectId}.zip");

                await _projectStructureService.UpdateProjectStructureFromTempFolder(projectId, tempFolder + "\\ProjectFolder", authorId, true);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                _logger.LogError(ex.Message);
            }
            finally
            {
                _projectStructureService.DeleteTempFolder(tempFolder);
            }
        }