示例#1
0
        public virtual void setUp()
        {
            Configure();

            trash = new DirectoryInfo(trashParent + "/trash" + DateTime.Now.Ticks + "." + (_testcount++));

            _directoriesToRemove.Add(trash.FullName);

            trash_git = new DirectoryInfo(Path.GetFullPath(trash + "/.git"));

            var mockSystemReader = new MockSystemReader();
            mockSystemReader.userGitConfig = new FileBasedConfig(
                new FileInfo(Path.Combine(trash_git.FullName, "usergitconfig")));
            SystemReader.setInstance(mockSystemReader);

            db = new Repository(trash_git);
            db.Create();

            string[] packs = {
                "pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f",
                "pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371",
                "pack-9fb5b411fe6dfa89cc2e6b89d2bd8e5de02b5745",
                "pack-546ff360fe3488adb20860ce3436a2d6373d2796",
                "pack-cbdeda40019ae0e6e789088ea0f51f164f489d14",
                "pack-e6d07037cbcf13376308a0a995d1fa48f8f76aaa",
                "pack-3280af9c07ee18a87705ef50b0cc4cd20266cf12"
            };

            var packDir = new DirectoryInfo(db.ObjectsDirectory + "/pack");

            foreach (var packname in packs)
            {
                new FileInfo("Resources/" + Core.Transport.IndexPack.GetPackFileName(packname)).CopyTo(packDir + "/" + Core.Transport.IndexPack.GetPackFileName(packname), true);
                new FileInfo("Resources/" + Core.Transport.IndexPack.GetIndexFileName(packname)).CopyTo(packDir + "/" + Core.Transport.IndexPack.GetIndexFileName(packname), true);
            }

            new FileInfo("Resources/packed-refs").CopyTo(trash_git.FullName + "/packed-refs", true);
        }
示例#2
0
        public virtual void setUp()
        {
            Configure();

            string name = GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name;

            // Cleanup old failed stuff
            recursiveDelete(new DirectoryInfo(trashParent.FullName), true, name, false);

            trash = new DirectoryInfo(trashParent + "/trash" + DateTime.Now.Ticks + "." + (_testcount++));
            trash_git = new DirectoryInfo(Path.GetFullPath(trash + "/.git"));

            var mockSystemReader = new MockSystemReader();
            mockSystemReader.userGitConfig = new FileBasedConfig(
                new FileInfo(Path.Combine(trash_git.FullName, "usergitconfig")));
            SystemReader.setInstance(mockSystemReader);

            db = new Repository(trash_git);
            db.Create();

            string[] packs = {
                "pack-34be9032ac282b11fa9babdc2b2a93ca996c9c2f",
                "pack-df2982f284bbabb6bdb59ee3fcc6eb0983e20371",
                "pack-9fb5b411fe6dfa89cc2e6b89d2bd8e5de02b5745",
                "pack-546ff360fe3488adb20860ce3436a2d6373d2796",
                "pack-e6d07037cbcf13376308a0a995d1fa48f8f76aaa",
                "pack-3280af9c07ee18a87705ef50b0cc4cd20266cf12"
            };

            var packDir = new DirectoryInfo(db.ObjectsDirectory + "/pack");

            foreach (var packname in packs)
            {
                new FileInfo("Resources/" + GitSharp.Transport.IndexPack.GetPackFileName(packname)).CopyTo(packDir + "/" + GitSharp.Transport.IndexPack.GetPackFileName(packname), true);
                new FileInfo("Resources/" + GitSharp.Transport.IndexPack.GetIndexFileName(packname)).CopyTo(packDir + "/" + GitSharp.Transport.IndexPack.GetIndexFileName(packname), true);
            }

            new FileInfo("Resources/packed-refs").CopyTo(trash_git.FullName + "/packed-refs", true);
        }
示例#3
0
        public void test007_readUserConfig()
        {
            MockSystemReader mockSystemReader = new MockSystemReader();
            SystemReader.setInstance(mockSystemReader);
            string hostname = mockSystemReader.getHostname();
            Config userGitConfig = mockSystemReader.userGitConfig;
            Config localConfig = new Config(userGitConfig);
            mockSystemReader.values.Clear();

            string authorName;
            string authorEmail;

            // no values defined nowhere
            authorName = localConfig.get(UserConfig.KEY).getAuthorName();
            authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
            Assert.AreEqual(Constants.UNKNOWN_USER_DEFAULT, authorName);
            Assert.AreEqual(Constants.UNKNOWN_USER_DEFAULT + "@" + hostname, authorEmail);

            // the system user name is defined
            mockSystemReader.values.put(Constants.OS_USER_NAME_KEY, "os user name");
            localConfig.uncache(UserConfig.KEY);
            authorName = localConfig.get(UserConfig.KEY).getAuthorName();
            Assert.AreEqual("os user name", authorName);

            if (hostname != null && hostname.Length != 0)
            {
                authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
                Assert.AreEqual("os user name@" + hostname, authorEmail);
            }

            // the git environment variables are defined
            mockSystemReader.values.put(Constants.GIT_AUTHOR_NAME_KEY, "git author name");
            mockSystemReader.values.put(Constants.GIT_AUTHOR_EMAIL_KEY, "author@email");
            localConfig.uncache(UserConfig.KEY);
            authorName = localConfig.get(UserConfig.KEY).getAuthorName();
            authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
            Assert.AreEqual("git author name", authorName);
            Assert.AreEqual("author@email", authorEmail);

            // the values are defined in the global configuration
            userGitConfig.setString("user", null, "name", "global username");
            userGitConfig.setString("user", null, "email", "author@globalemail");
            authorName = localConfig.get(UserConfig.KEY).getAuthorName();
            authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
            Assert.AreEqual("global username", authorName);
            Assert.AreEqual("author@globalemail", authorEmail);

            // the values are defined in the local configuration
            localConfig.setString("user", null, "name", "local username");
            localConfig.setString("user", null, "email", "author@localemail");
            authorName = localConfig.get(UserConfig.KEY).getAuthorName();
            authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
            Assert.AreEqual("local username", authorName);
            Assert.AreEqual("author@localemail", authorEmail);

            authorName = localConfig.get(UserConfig.KEY).getCommitterName();
            authorEmail = localConfig.get(UserConfig.KEY).getCommitterEmail();
            Assert.AreEqual("local username", authorName);
            Assert.AreEqual("author@localemail", authorEmail);
        }