Example #1
0
        /// <summary>
        /// Delete a repo
        /// </summary>
        /// <param name="TeamProjectName"></param>
        /// <param name="RepoName"></param>
        private static void RemoveRepoToRecycleBin(string TeamProjectName, string RepoName)
        {
            GitRepository gitRepo = GitClient.GetRepositoryAsync(TeamProjectName, RepoName).Result;

            GitClient.DeleteRepositoryAsync(gitRepo.Id).Wait();

            Console.WriteLine("Removed repo: " + RepoName);
        }
Example #2
0
        /// <summary>
        /// delete fork if exists
        ///
        /// if repo does not exist, just return gracefully
        /// </summary>
        /// <param name="client">extension entry-point</param>
        /// <param name="forkName">fork definition</param>
        /// <returns>fork deletion result</returns>
        internal static async Task <bool> DeleteForkIfExists(this GitHttpClient client, string forkName)
        {
            var repo = await client.LoadGitRepositoryIfExists(forkName);

            if (repo == null)
            {
                return(false);
            }

            await client.DeleteRepositoryAsync(repo.Id);

            return(true);
        }
Example #3
0
        //public static async Task CloneRepositoryAsync ( this GitHttpClient source, GitRepository repo, string outputPath, CancellationToken cancellationToken )
        //{
        //    Logger.Debug($"Cloning repository: Name = '{repo.Name}'");

        //    //Create the folder if it does not exist yet
        //    await FileSystem.CreateDirectoryAsync(outputPath, true, cancellationToken).ConfigureAwait(false);

        //    try
        //    {
        //        using (var stream = await source.GetItemZipAsync(repo.Id, "/", cancellationToken: cancellationToken).ConfigureAwait(false))
        //        {
        //            Logger.Debug($"Extracting repo to '{outputPath}");
        //            var fileCount = await FileSystem.ExtractZipAsync(stream, outputPath, cancellationToken: cancellationToken).ConfigureAwait(false);
        //            Logger.Debug($"Extracted {fileCount} files");
        //        };
        //    } catch (VssServiceResponseException e)
        //    {
        //        //Ignore warnings
        //        if (e.LogLevel != EventLogEntryType.Warning)
        //            throw;

        //        Logger.Warning($"Cloning repository caused warning: Name = '{repo.Name}', Message = '{e.Message}");
        //    };
        //}

        public static async Task DeleteRepositoryAsync(this GitHttpClient source, GitRepository repo, CancellationToken cancellationToken)
        {
            Logger.Debug($"Deleting Repository: Name = '{repo.Name}'");

            await source.DeleteRepositoryAsync(repo.Id, cancellationToken : cancellationToken).ConfigureAwait(false);
        }