src/SyncTool.Git/main/RepositoryAccess/RepositoryVerifier.cs
/// <summary>
/// Verifies that the specified path points to a valid repository usable by SyncTool
/// (a repository with the expected tags and default branches as created by RepositoryInitHelper)
/// </summary>
Verifies that the specified path points to a valid repository usable by SyncTool
(a repository with the expected tags and default branches as created by RepositoryInitHelper)
Verifies that the specified path points to a valid repository usable by SyncTool ( a repository with the expected tags and default branches as created by RepositoryInitHelper )
public static bool IsValid(string path)
        {
            if (!Directory.Exists(path) || !Repository.IsValid(path))
            {
                return false;
            }
            using (var repository = new Repository(path))
            {
                if (!repository.Info.IsBare)
                {
                    return false;
                }
                if (!repository.LocalBranchExists(RepositoryInitHelper.ConfigurationBranchName))
                {
                    return false;
                }
                if (repository.Tags[RepositoryInitHelper.InitialCommitTagName] == null)
                {
                    return false;
                }
                foreach (var localBranch in repository.GetLocalBranches())
                {
                    var gitDirectory = new GitDirectory(null, "Irrelevant", localBranch.Tip);
                    if (!gitDirectory.FileExists(RepositoryInfoFile.RepositoryInfoFileName))
                    {
                        return false;
                    }
                }                
            }
            return true;
        }
public static bool IsValid ( string path ) { if ( ! Directory . Exists ( path ) || ! Repository . IsValid ( path ) ) { return false ; } using ( var repository = new Repository ( path ) ) { if ( ! repository . Info . IsBare ) { return false ; } if ( ! repository . LocalBranchExists ( RepositoryInitHelper . ConfigurationBranchName ) ) { return false ; } if ( repository . Tags [ RepositoryInitHelper . InitialCommitTagName ] == null ) { return false ; } foreach ( var localBranch in repository . GetLocalBranches ( ) ) { var gitDirectory = new GitDirectory ( null , " " , localBranch . Tip ) ; if ( ! gitDirectory . FileExists ( RepositoryInfoFile . RepositoryInfoFileName ) ) { return false ; } } } return true ; }
Verifies that the specified path points to a valid repository usable by SyncTool
(a repository with the expected tags and default branches as created by RepositoryInitHelper)
Verifies that the specified path points to a valid repository usable by SyncTool ( a repository with the expected tags and default branches as created by RepositoryInitHelper )
// check if the directory exists and is a valid git repository // the repository needs to be a bare repository // ensure there is a configuration branch // ensure there is a tag for the initial commit // check if there is a repository info file in the root (on all branches) //TODO: verify content of repository info file
path
string