Esempio n. 1
0
		public virtual void RepositoryWithNoSubmodules()
		{
			SubmoduleSyncCommand command = new SubmoduleSyncCommand(db);
			IDictionary<string, string> modules = command.Call();
			NUnit.Framework.Assert.IsNotNull(modules);
			NUnit.Framework.Assert.IsTrue(modules.IsEmpty());
		}
Esempio n. 2
0
        public virtual void RepositoryWithNoSubmodules()
        {
            SubmoduleSyncCommand         command = new SubmoduleSyncCommand(db);
            IDictionary <string, string> modules = command.Call();

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

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

            editor.Add(new _PathEdit_96(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);
            modulesConfig.Save();
            Repository subRepo = Git.CloneRepository().SetURI(db.Directory.ToURI().ToString()
                                                              ).SetDirectory(new FilePath(db.WorkTree, path)).Call().GetRepository();

            AddRepoToClose(subRepo);
            NUnit.Framework.Assert.IsNotNull(subRepo);
            SubmoduleWalk generator = SubmoduleWalk.ForIndex(db);

            NUnit.Framework.Assert.IsTrue(generator.Next());
            NUnit.Framework.Assert.IsNull(generator.GetConfigUrl());
            NUnit.Framework.Assert.AreEqual(url, generator.GetModulesUrl());
            SubmoduleSyncCommand         command = new SubmoduleSyncCommand(db);
            IDictionary <string, string> synced  = command.Call();

            NUnit.Framework.Assert.IsNotNull(synced);
            NUnit.Framework.Assert.AreEqual(1, synced.Count);
            KeyValuePair <string, string> module = synced.EntrySet().Iterator().Next();

            NUnit.Framework.Assert.AreEqual(path, module.Key);
            NUnit.Framework.Assert.AreEqual(url, module.Value);
            generator = SubmoduleWalk.ForIndex(db);
            NUnit.Framework.Assert.IsTrue(generator.Next());
            NUnit.Framework.Assert.AreEqual(url, generator.GetConfigUrl());
            Repository subModRepository = generator.GetRepository();

            AddRepoToClose(subModRepository);
            StoredConfig submoduleConfig = subModRepository.GetConfig();

            NUnit.Framework.Assert.AreEqual(url, submoduleConfig.GetString(ConfigConstants.CONFIG_REMOTE_SECTION
                                                                           , Constants.DEFAULT_REMOTE_NAME, ConfigConstants.CONFIG_KEY_URL));
        }
Esempio n. 4
0
		public virtual void RepositoryWithSubmodule()
		{
			WriteTrashFile("file.txt", "content");
			Git git = Git.Wrap(db);
			git.Add().AddFilepattern("file.txt").Call();
			git.Commit().SetMessage("create file").Call();
			ObjectId id = ObjectId.FromString("abcd1234abcd1234abcd1234abcd1234abcd1234");
			string path = "sub";
			DirCache cache = db.LockDirCache();
			DirCacheEditor editor = cache.Editor();
			editor.Add(new _PathEdit_96(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);
			modulesConfig.Save();
			Repository subRepo = Git.CloneRepository().SetURI(db.Directory.ToURI().ToString()
				).SetDirectory(new FilePath(db.WorkTree, path)).Call().GetRepository();
			AddRepoToClose(subRepo);
			NUnit.Framework.Assert.IsNotNull(subRepo);
			SubmoduleWalk generator = SubmoduleWalk.ForIndex(db);
			NUnit.Framework.Assert.IsTrue(generator.Next());
			NUnit.Framework.Assert.IsNull(generator.GetConfigUrl());
			NUnit.Framework.Assert.AreEqual(url, generator.GetModulesUrl());
			SubmoduleSyncCommand command = new SubmoduleSyncCommand(db);
			IDictionary<string, string> synced = command.Call();
			NUnit.Framework.Assert.IsNotNull(synced);
			NUnit.Framework.Assert.AreEqual(1, synced.Count);
			KeyValuePair<string, string> module = synced.EntrySet().Iterator().Next();
			NUnit.Framework.Assert.AreEqual(path, module.Key);
			NUnit.Framework.Assert.AreEqual(url, module.Value);
			generator = SubmoduleWalk.ForIndex(db);
			NUnit.Framework.Assert.IsTrue(generator.Next());
			NUnit.Framework.Assert.AreEqual(url, generator.GetConfigUrl());
			Repository subModRepository = generator.GetRepository();
			AddRepoToClose(subModRepository);
			StoredConfig submoduleConfig = subModRepository.GetConfig();
			NUnit.Framework.Assert.AreEqual(url, submoduleConfig.GetString(ConfigConstants.CONFIG_REMOTE_SECTION
				, Constants.DEFAULT_REMOTE_NAME, ConfigConstants.CONFIG_KEY_URL));
		}