Ejemplo n.º 1
0
 private static bool MoveDirectoryUpUntilRepositoryRoot(FilesystemDirectory directory)
 {
     while (true)
     {
         if (directory.FileExists(stateFilePath))
         {
             return(true);
         }
         if (!directory.MoveOneDirectoryUp())
         {
             return(false);
         }
     }
 }
Ejemplo n.º 2
0
        private LocalRepository(string directoryPath, bool allowNonLinkedDirectory = false)
        {
            var directory = new FilesystemDirectory(directoryPath);

            directoryPath = directory.PhysicalPath;
            var isLinked = MoveDirectoryUpUntilRepositoryRoot(directory);

            if (isLinked)
            {
                this.FullRepositoryName = directory.ReadTextFile(stateFilePath).SplitInLines()[0];
            }
            else if (allowNonLinkedDirectory)
            {
                this.FullRepositoryName = null;
                directory = new FilesystemDirectory(directoryPath);
            }
            else
            {
                throw new InvalidOperationException($"{directoryPath} is not linked to any remote repository");
            }

            this.Directory = directory;
        }
Ejemplo n.º 3
0
 static LocalRepository()
 {
     stateFilePath = FilesystemDirectory.CombinePath(databaseDirectory, stateFileName);
     treeFilePath  = FilesystemDirectory.CombinePath(databaseDirectory, treeFileName);
 }