Example #1
0
        public void GivenNewRepository_WhenBare_ThenInitCreatesRefsDirectory()
        {
            Gitlet.Init(Bare());

            var refsPath = Files.CurrentPath.Combine("refs");

            Assert.That(Directory.Exists(refsPath), Is.True);
        }
Example #2
0
        public void GivenNewRepository_WhenNotBare_ThenInitCreatesRefsHeadsDirectory()
        {
            Gitlet.Init();

            var refsHeadsPath = Files.CurrentPath.Combine(".gitlet", "refs", "heads");

            Assert.That(Directory.Exists(refsHeadsPath), Is.True);
        }
Example #3
0
        public void GivenNewRepository_WhenNotBare_ThenInitCreatesObjectsDirectory()
        {
            Gitlet.Init();

            var objectsPath = Files.CurrentPath.Combine(".gitlet", "objects");

            Assert.That(Directory.Exists(objectsPath), Is.True);
        }
Example #4
0
        public void GivenNewRepository_WhenBare_ThenInitCreatesHead()
        {
            Gitlet.Init(Bare());

            var head = Files.CurrentPath.Combine("HEAD").ReadAllText();

            Assert.That(head, Is.EqualTo("ref: refs/heads/master\n"));
        }
Example #5
0
        public void GivenNewRepository_WhenBare_ThenInitCreatesConfig()
        {
            Gitlet.Init(Bare());

            var config = Files.CurrentPath.Combine("config").ReadAllText();

            Assert.That(config, Is.EqualTo("[core]\n    bare = true\n"));
        }
Example #6
0
        public void GivenANewRepository_WhenSpecifiedFileExists_ThenAddCreatesAnObjectFile()
        {
            NewRepositoryAssumptions();

            Files.CurrentPath.Combine("number.txt").WriteAllText("first!");
            Gitlet.Add("number.txt");

            var objectFile = Files.CurrentPath.Combine(".gitlet", "objects", Util.Hash("first!")).ReadAllText();

            Assert.That(objectFile, Is.EqualTo("first!"));
        }
Example #7
0
        public void GivenANewRepository_WhenSpecifiedFileExists_ThenAddCreatesIndex()
        {
            NewRepositoryAssumptions();

            Files.CurrentPath.Combine("number.txt").WriteAllText("first!");
            Gitlet.Add("number.txt");

            var index = Files.CurrentPath.Combine(".gitlet", "index").ReadAllText();

            var expectedIndex = string.Format("number.txt 0 {0}\n", Util.Hash("first!"));

            Assert.That(index, Is.EqualTo(expectedIndex));
        }
Example #8
0
        public void GivenExistingRepository_ThenInitThrowException()
        {
            Gitlet.Init();

            Assert.That(() => Gitlet.Init(), Throws.Exception.With.Message.EqualTo("unsupported"));
        }
Example #9
0
 public static void Init()
 {
     Gitlet.Init();
 }
Example #10
0
 public static void FirstAdd()
 {
     Files.CurrentPath.Combine("number.txt").WriteAllText("first!");
     Gitlet.Add("number.txt");
 }
Example #11
0
        public void GivenANewRepository_WhenSpecifiedFileDoesNotExists_ThenAddThrowsException()
        {
            NewRepositoryAssumptions();

            Assert.That(() => Gitlet.Add("number.txt"), Throws.Exception.With.Message.ContainsSubstring("did not match any files"));
        }