GitSharp.Repository.Dispose C# (CSharp) Method

Dispose() public method

public Dispose ( ) : void
return void
        public void Dispose()
        {
            Close();
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// Checks if the directory given by the path is a valid git repository.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="bare"></param>
        /// <returns>Returns true if the given path is a valid git repository, false otherwise.</returns>
        public static bool IsValid(string path, bool bare)
        {
            if (!bare)
            {
                if (!Regex.IsMatch(path, "\\.git[/\\\\]?$"))
                    path = Path.Combine(path, ".git");
            }

            if (!DirExists(path))
                return false;
            if (!FileExists(Path.Combine(path, "HEAD")))
                return false;
            if (!FileExists(Path.Combine(path, "config")))
                return false;
            //if (!DirExists(Path.Combine(path, "description")))
            //    return false;
            //if (!DirExists(Path.Combine(path, "hooks")))
            //   return false;
            //if (!DirExists(Path.Combine(path, "info")))
            //    return false;
            //if (!DirExists(Path.Combine(path, "info/exclude")))
            //    return false;
             			if (!DirExists(Path.Combine(path, "objects")))
                return false;
            if (!DirExists(Path.Combine(path, "objects/info")))
                return false;
            if (!DirExists(Path.Combine(path, "objects/pack")))
                return false;
            if (!DirExists(Path.Combine(path, "refs")))
                return false;
            if (!DirExists(Path.Combine(path, "refs/heads")))
                return false;
            if (!DirExists(Path.Combine(path, "refs/tags")))
                return false;

            Repository repo = null;

            try
            {
                // let's see if it loads without throwing an exception
                repo = new Repository(path);
            }
            catch (Exception)
            {
                return false;
            }
            finally
            {
                if (repo != null)
                {
                    repo.Dispose();
                }
            }
            return true;
        }
All Usage Examples Of GitSharp.Repository::Dispose