exists() public method

public exists ( ) : bool
return bool
コード例 #1
0
ファイル: Repository.cs プロジェクト: kkl713/GitSharp
        static private List <RepositoryListener> allListeners = new List <RepositoryListener>(); //TODO: make thread safe

        /**
         * Construct a representation of a Git repository.
         *
         * @param d
         *            GIT_DIR (the location of the repository metadata).
         * @throws IOException
         *             the repository appears to already exist but cannot be
         *             accessed.
         */
        public Repository(DirectoryInfo gitDirectory)
        {
            Directory       = gitDirectory;
            _refDb          = new RefDatabase(this);
            _objectDatabase = new ObjectDirectory(new DirectoryInfo(FS.resolve(gitDirectory, "objects").FullName));

            var userConfig = SystemReader.getInstance().openUserConfig();

            try
            {
                userConfig.load();
            }
            catch (ConfigInvalidException e1)
            {
                Dispose();

                throw new IOException("User config file "
                                      + userConfig.getFile().FullName + " invalid: "
                                      + e1, e1);
            }

            Config = new RepositoryConfig(userConfig, (FileInfo)FS.resolve(gitDirectory, "config"));

            WorkingDirectory = gitDirectory.Parent;

            if (_objectDatabase.exists())
            {
                try
                {
                    Config.load();
                }
                catch (ConfigInvalidException e1)
                {
                    Dispose();
                    throw new IOException("Unknown repository format", e1);
                }

                string repositoryFormatVersion = Config.getString("core", null, "repositoryFormatVersion");

                if (!"0".Equals(repositoryFormatVersion))
                {
                    Dispose();
                    throw new IOException("Unknown repository format \""
                                          + repositoryFormatVersion + "\"; expected \"0\".");
                }
            }
        }
コード例 #2
0
ファイル: Repository.cs プロジェクト: georgeck/GitSharp
        /**
         * Construct a representation of a Git repository.
         *
         * @param d
         *            GIT_DIR (the location of the repository metadata).
         * @throws IOException
         *             the repository appears to already exist but cannot be
         *             accessed.
         */
        public Repository(DirectoryInfo gitDirectory)
        {
            Directory = gitDirectory;
            _refDb = new RefDatabase(this);
            _objectDatabase = new ObjectDirectory(new DirectoryInfo(FS.resolve(gitDirectory, "objects").FullName));

            var userConfig = SystemReader.getInstance().openUserConfig();

            try
            {
                userConfig.load();
            }
            catch (ConfigInvalidException e1)
            {
                throw new IOException("User config file "
                    + userConfig.getFile().FullName + " invalid: "
                    + e1, e1);
            }

            Config = new RepositoryConfig(userConfig, (FileInfo)FS.resolve(gitDirectory, "config"));

            WorkingDirectory = gitDirectory.Parent;

            if (_objectDatabase.exists())
            {
                try
                {
                    Config.load();
                }
                catch (ConfigInvalidException e1)
                {
                    throw new IOException("Unknown repository format", e1);
                }

                string repositoryFormatVersion = Config.getString("core", null, "repositoryFormatVersion");

                if (!"0".Equals(repositoryFormatVersion))
                {
                    throw new IOException("Unknown repository format \""
                                          + repositoryFormatVersion + "\"; expected \"0\".");
                }
            }
        }