Exemplo n.º 1
0
        public virtual void RepositoryWithUnconfiguredSubmodule()
        {
            ObjectId       id     = ObjectId.FromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
            string         path   = "sub";
            DirCache       cache  = db.LockDirCache();
            DirCacheEditor editor = cache.Editor();

            editor.Add(new _PathEdit_137(id, path));
            editor.Commit();
            FileBasedConfig modulesConfig = new FileBasedConfig(new FilePath(db.WorkTree, Constants
                                                                             .DOT_GIT_MODULES), db.FileSystem);

            modulesConfig.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants
                                    .CONFIG_KEY_PATH, path);
            string url = "git://server/repo.git";

            modulesConfig.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants
                                    .CONFIG_KEY_URL, url);
            string update = "rebase";

            modulesConfig.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants
                                    .CONFIG_KEY_UPDATE, update);
            modulesConfig.Save();
            SubmoduleUpdateCommand command = new SubmoduleUpdateCommand(db);
            ICollection <string>   updated = command.Call();

            NUnit.Framework.Assert.IsNotNull(updated);
            NUnit.Framework.Assert.IsTrue(updated.IsEmpty());
        }
Exemplo n.º 2
0
		public virtual void RepositoryWithNoSubmodules()
		{
			SubmoduleUpdateCommand command = new SubmoduleUpdateCommand(db);
			ICollection<string> modules = command.Call();
			NUnit.Framework.Assert.IsNotNull(modules);
			NUnit.Framework.Assert.IsTrue(modules.IsEmpty());
		}
Exemplo n.º 3
0
        public virtual void RepositoryWithNoSubmodules()
        {
            SubmoduleUpdateCommand command = new SubmoduleUpdateCommand(db);
            ICollection <string>   modules = command.Call();

            NUnit.Framework.Assert.IsNotNull(modules);
            NUnit.Framework.Assert.IsTrue(modules.IsEmpty());
        }
Exemplo n.º 4
0
        public virtual void RepositoryWithInitializedSubmodule()
        {
            ObjectId       id     = ObjectId.FromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
            string         path   = "sub";
            DirCache       cache  = db.LockDirCache();
            DirCacheEditor editor = cache.Editor();

            editor.Add(new _PathEdit_172(id, path));
            editor.Commit();
            Repository subRepo = Git.Init().SetBare(false).SetDirectory(new FilePath(db.WorkTree
                                                                                     , path)).Call().GetRepository();

            NUnit.Framework.Assert.IsNotNull(subRepo);
            SubmoduleUpdateCommand command = new SubmoduleUpdateCommand(db);
            ICollection <string>   updated = command.Call();

            NUnit.Framework.Assert.IsNotNull(updated);
            NUnit.Framework.Assert.IsTrue(updated.IsEmpty());
        }
Exemplo n.º 5
0
        public virtual void RepositoryWithSubmodule()
        {
            WriteTrashFile("file.txt", "content");
            Git git = Git.Wrap(db);

            git.Add().AddFilepattern("file.txt").Call();
            RevCommit      commit = git.Commit().SetMessage("create file").Call();
            string         path   = "sub";
            DirCache       cache  = db.LockDirCache();
            DirCacheEditor editor = cache.Editor();

            editor.Add(new _PathEdit_94(commit, path));
            editor.Commit();
            StoredConfig config = ((FileBasedConfig)db.GetConfig());

            config.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants.
                             CONFIG_KEY_URL, db.Directory.ToURI().ToString());
            config.Save();
            FileBasedConfig modulesConfig = new FileBasedConfig(new FilePath(db.WorkTree, Constants
                                                                             .DOT_GIT_MODULES), db.FileSystem);

            modulesConfig.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants
                                    .CONFIG_KEY_PATH, path);
            modulesConfig.Save();
            SubmoduleUpdateCommand command = new SubmoduleUpdateCommand(db);
            ICollection <string>   updated = command.Call();

            NUnit.Framework.Assert.IsNotNull(updated);
            NUnit.Framework.Assert.AreEqual(1, updated.Count);
            NUnit.Framework.Assert.AreEqual(path, updated.Iterator().Next());
            SubmoduleWalk generator = SubmoduleWalk.ForIndex(db);

            NUnit.Framework.Assert.IsTrue(generator.Next());
            Repository subRepo = generator.GetRepository();

            AddRepoToClose(subRepo);
            NUnit.Framework.Assert.IsNotNull(subRepo);
            NUnit.Framework.Assert.AreEqual(commit, subRepo.Resolve(Constants.HEAD));
        }
Exemplo n.º 6
0
		public virtual void RepositoryWithSubmodule()
		{
			WriteTrashFile("file.txt", "content");
			Git git = Git.Wrap(db);
			git.Add().AddFilepattern("file.txt").Call();
			RevCommit commit = git.Commit().SetMessage("create file").Call();
			string path = "sub";
			DirCache cache = db.LockDirCache();
			DirCacheEditor editor = cache.Editor();
			editor.Add(new _PathEdit_94(commit, path));
			editor.Commit();
			StoredConfig config = ((FileBasedConfig)db.GetConfig());
			config.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants.
				CONFIG_KEY_URL, db.Directory.ToURI().ToString());
			config.Save();
			FileBasedConfig modulesConfig = new FileBasedConfig(new FilePath(db.WorkTree, Constants
				.DOT_GIT_MODULES), db.FileSystem);
			modulesConfig.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants
				.CONFIG_KEY_PATH, path);
			modulesConfig.Save();
			SubmoduleUpdateCommand command = new SubmoduleUpdateCommand(db);
			ICollection<string> updated = command.Call();
			NUnit.Framework.Assert.IsNotNull(updated);
			NUnit.Framework.Assert.AreEqual(1, updated.Count);
			NUnit.Framework.Assert.AreEqual(path, updated.Iterator().Next());
			SubmoduleWalk generator = SubmoduleWalk.ForIndex(db);
			NUnit.Framework.Assert.IsTrue(generator.Next());
			Repository subRepo = generator.GetRepository();
			AddRepoToClose(subRepo);
			NUnit.Framework.Assert.IsNotNull(subRepo);
			NUnit.Framework.Assert.AreEqual(commit, subRepo.Resolve(Constants.HEAD));
		}
Exemplo n.º 7
0
		public virtual void RepositoryWithInitializedSubmodule()
		{
			ObjectId id = ObjectId.FromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
			string path = "sub";
			DirCache cache = db.LockDirCache();
			DirCacheEditor editor = cache.Editor();
			editor.Add(new _PathEdit_172(id, path));
			editor.Commit();
			Repository subRepo = Git.Init().SetBare(false).SetDirectory(new FilePath(db.WorkTree
				, path)).Call().GetRepository();
			NUnit.Framework.Assert.IsNotNull(subRepo);
			SubmoduleUpdateCommand command = new SubmoduleUpdateCommand(db);
			ICollection<string> updated = command.Call();
			NUnit.Framework.Assert.IsNotNull(updated);
			NUnit.Framework.Assert.IsTrue(updated.IsEmpty());
		}
Exemplo n.º 8
0
		public virtual void RepositoryWithUnconfiguredSubmodule()
		{
			ObjectId id = ObjectId.FromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
			string path = "sub";
			DirCache cache = db.LockDirCache();
			DirCacheEditor editor = cache.Editor();
			editor.Add(new _PathEdit_137(id, path));
			editor.Commit();
			FileBasedConfig modulesConfig = new FileBasedConfig(new FilePath(db.WorkTree, Constants
				.DOT_GIT_MODULES), db.FileSystem);
			modulesConfig.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants
				.CONFIG_KEY_PATH, path);
			string url = "git://server/repo.git";
			modulesConfig.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants
				.CONFIG_KEY_URL, url);
			string update = "rebase";
			modulesConfig.SetString(ConfigConstants.CONFIG_SUBMODULE_SECTION, path, ConfigConstants
				.CONFIG_KEY_UPDATE, update);
			modulesConfig.Save();
			SubmoduleUpdateCommand command = new SubmoduleUpdateCommand(db);
			ICollection<string> updated = command.Call();
			NUnit.Framework.Assert.IsNotNull(updated);
			NUnit.Framework.Assert.IsTrue(updated.IsEmpty());
		}