Esempio n. 1
0
 public override void SetUp()
 {
     base.SetUp();
     dbTarget = CreateWorkRepository();
     source = new Git(db);
     target = new Git(dbTarget);
     // put some file in the source repo
     sourceFile = new FilePath(db.WorkTree, "SomeFile.txt");
     WriteToFile(sourceFile, "Hello world");
     // and commit it
     source.Add().AddFilepattern("SomeFile.txt").Call();
     source.Commit().SetMessage("Initial commit for source").Call();
     // configure the target repo to connect to the source via "origin"
     StoredConfig targetConfig = ((FileBasedConfig)dbTarget.GetConfig());
     targetConfig.SetString("branch", "master", "remote", "origin");
     targetConfig.SetString("branch", "master", "merge", "refs/heads/master");
     RemoteConfig config = new RemoteConfig(targetConfig, "origin");
     config.AddURI(new URIish(source.GetRepository().WorkTree.GetPath()));
     config.AddFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
     config.Update(targetConfig);
     targetConfig.Save();
     targetFile = new FilePath(dbTarget.WorkTree, "SomeFile.txt");
     // make sure we have the same content
     target.Pull().Call();
     target.Checkout().SetStartPoint("refs/remotes/origin/master").SetName("master").Call
         ();
     targetConfig.SetString("branch", "master", "merge", "refs/heads/master");
     targetConfig.SetBoolean("branch", "master", "rebase", true);
     targetConfig.Save();
     AssertFileContentsEqual(targetFile, "Hello world");
 }
		public virtual void TestWorkdirIsParentDir_CreateRepositoryFromDotGitGitDir()
		{
			FilePath gitDir = GetFile("workdir", Constants.DOT_GIT);
			Repository repo = new FileRepository(gitDir);
			string workdir = repo.WorkTree.GetName();
			NUnit.Framework.Assert.AreEqual(workdir, "workdir");
		}
		public override void Setup ()
		{
			// Generate directories and a svn util.
			RemotePath = new FilePath (FileService.CreateTempDirectory () + Path.DirectorySeparatorChar);
			LocalPath = new FilePath (FileService.CreateTempDirectory () + Path.DirectorySeparatorChar);
			Directory.CreateDirectory (RemotePath.FullPath + "repo.git");
			RemoteUrl = "file:///" + RemotePath.FullPath + "repo.git";

			// Initialize the bare repo.
			var ci = new InitCommand ();
			ci.SetDirectory (new Sharpen.FilePath (RemotePath.FullPath + "repo.git"));
			ci.SetBare (true);
			ci.Call ();
			var bare = new FileRepository (new Sharpen.FilePath (RemotePath.FullPath + "repo.git"));
			string branch = Constants.R_HEADS + "master";

			RefUpdate head = bare.UpdateRef (Constants.HEAD);
			head.DisableRefLog ();
			head.Link (branch);

			// Check out the repository.
			Checkout (LocalPath, RemoteUrl);
			Repo = GetRepo (LocalPath, RemoteUrl);
			DotDir = ".git";
		}
Esempio n. 4
0
		public override void SetUp()
		{
			base.SetUp();
			db = CreateBareRepository();
			reader = db.NewObjectReader();
			test = new TestRepository<FileRepository>(db);
		}
		public override void Setup ()
		{
			// Generate directories and a svn util.
			rootUrl = new FilePath (FileService.CreateTempDirectory () + Path.DirectorySeparatorChar);
			rootCheckout = new FilePath (FileService.CreateTempDirectory () + Path.DirectorySeparatorChar);
			Directory.CreateDirectory (rootUrl.FullPath + "repo.git");
			repoLocation = "file:///" + rootUrl.FullPath + "repo.git";

			// Initialize the bare repo.
			InitCommand ci = new InitCommand ();
			ci.SetDirectory (new Sharpen.FilePath (rootUrl.FullPath + "repo.git"));
			ci.SetBare (true);
			ci.Call ();
			FileRepository bare = new FileRepository (new Sharpen.FilePath (rootUrl.FullPath + "repo.git"));
			string branch = Constants.R_HEADS + "master";

			RefUpdate head = bare.UpdateRef (Constants.HEAD);
			head.DisableRefLog ();
			head.Link (branch);

			// Check out the repository.
			Checkout (rootCheckout, repoLocation);
			repo = GetRepo (rootCheckout, repoLocation);
			DOT_DIR = ".git";
		}
		public virtual void TestNotBare_CreateRepositoryFromDotGitGitDir()
		{
			FilePath gitDir = GetFile("workdir", Constants.DOT_GIT);
			Repository repo = new FileRepository(gitDir);
			NUnit.Framework.Assert.IsFalse(repo.IsBare);
			AssertWorkdirPath(repo, "workdir");
			AssertGitdirPath(repo, "workdir", Constants.DOT_GIT);
		}
Esempio n. 7
0
		public override void SetUp()
		{
			base.SetUp();
			WindowCacheConfig cfg = new WindowCacheConfig();
			cfg.SetStreamFileThreshold(streamThreshold);
			WindowCache.Reconfigure(cfg);
			repo = CreateBareRepository();
			wc = (WindowCursor)repo.NewObjectReader();
		}
Esempio n. 8
0
 public virtual void Test000_openrepo_default_workDirSet()
 {
     FilePath repo1Parent = new FilePath(trash.GetParentFile(), "r1");
     Repository repo1initial = new FileRepository(new FilePath(repo1Parent, Constants.
         DOT_GIT));
     repo1initial.Create();
     repo1initial.Close();
     FilePath theDir = new FilePath(repo1Parent, Constants.DOT_GIT);
     FileRepository r = new FileRepositoryBuilder().SetWorkTree(repo1Parent).Build();
     AssertEqualsPath(theDir, r.Directory);
     AssertEqualsPath(repo1Parent, r.WorkTree);
     AssertEqualsPath(new FilePath(theDir, "index"), r.GetIndexFile());
     AssertEqualsPath(new FilePath(theDir, "objects"), ((ObjectDirectory)r.ObjectDatabase
         ).GetDirectory());
 }
Esempio n. 9
0
 public virtual void Test007_Open()
 {
     FileRepository db2 = new FileRepository(db.Directory);
     NUnit.Framework.Assert.AreEqual(db.Directory, db2.Directory);
     NUnit.Framework.Assert.AreEqual(((ObjectDirectory)db.ObjectDatabase).GetDirectory
         (), ((ObjectDirectory)db2.ObjectDatabase).GetDirectory());
     NUnit.Framework.Assert.AreNotSame(((FileBasedConfig)db.GetConfig()), ((FileBasedConfig
         )db2.GetConfig()));
 }
Esempio n. 10
0
        public InstallerMessage SetRepository(string uri, string user, string password, bool replaceExisting = false)
        {
            LastException = null;

            try
            {
                if (RepoIsClonned())
                {
                    if (replaceExisting)
                    {
                        try
                        {
                            Directory.Delete(_repoPath, true);
                        }
                        catch (Exception e)
                        {
                            throw new Exception("Could not delete current repository. " + e.Message);
                        }

                    }
                    else
                    {
                        if (!GitHelper.isValidLocalRepository(Path.Combine(_repoPath, @".git")))
                            throw new Exception("There are files stored where the repository would be cloned. Clone canceled");

                        var repo = new FileRepository(Path.Combine(_repoPath, @".git"));

                        var c = repo.GetConfig();
                        var remoteUrl = c.GetString("remote", "origin", "url");
                        var isSameRepo = remoteUrl != uri;

                        if (!isSameRepo)
                        {
                            var remotes = c.GetSubsections("remote");

                            foreach (var remote in remotes)
                            {
                                var rUrl = c.GetString("remote", remote, "url");

                                if (String.IsNullOrEmpty(remoteUrl)) // let's keep the first we find
                                    remoteUrl = rUrl;

                                if (rUrl == uri)
                                {
                                    isSameRepo = true;
                                    break;
                                }
                            }

                            if (!isSameRepo)
                            {
                                if (!String.IsNullOrEmpty(remoteUrl))
                                    throw new Exception("There is already a repository pointing to " + remoteUrl + " where the wiki should be cloned.");

                                throw new Exception("There is already a repository where the wiki should be cloned.");
                            }
                        }

                        return InstallerMessage.Success;
                    }
                }

                if (!Directory.Exists(_repoPath))
                {
                    if (!Directory.Exists(Path.Combine(_appRoot, "App_Data")))
                        Directory.CreateDirectory(Path.Combine(_appRoot, "App_Data"));

                    Directory.CreateDirectory(_repoPath);
                }
                var cmd = new CloneCommand();

                if(!String.IsNullOrEmpty(user))
                    cmd.SetCredentialsProvider(new UsernamePasswordCredentialsProvider(user, password));

                cmd.SetURI(uri);
                cmd.SetCloneSubmodules(true);
                cmd.SetDirectory(_repoPath);

                cmd.Call();
            }
            catch (Exception e)
            {
                LastException = e;
                return InstallerMessage.ExceptionThrown;
            }

            if (RepoIsClonned())
            {
                WG.Settings.Repository = uri;
                return InstallerMessage.Success;
            }

            return InstallerMessage.UnkownFailure;
        }
Esempio n. 11
0
 public virtual void Test000_openrepo_default_relative_workdirconfig()
 {
     FilePath repo1Parent = new FilePath(trash.GetParentFile(), "r1");
     FilePath workdir = new FilePath(trash.GetParentFile(), "rw");
     FileUtils.Mkdir(workdir);
     FileRepository repo1initial = new FileRepository(new FilePath(repo1Parent, Constants
         .DOT_GIT));
     repo1initial.Create();
     FileBasedConfig cfg = ((FileBasedConfig)repo1initial.GetConfig());
     cfg.SetString("core", null, "worktree", "../../rw");
     cfg.Save();
     repo1initial.Close();
     FilePath theDir = new FilePath(repo1Parent, Constants.DOT_GIT);
     FileRepository r = new FileRepositoryBuilder().SetGitDir(theDir).Build();
     AssertEqualsPath(theDir, r.Directory);
     AssertEqualsPath(workdir, r.WorkTree);
     AssertEqualsPath(new FilePath(theDir, "index"), r.GetIndexFile());
     AssertEqualsPath(new FilePath(theDir, "objects"), ((ObjectDirectory)r.ObjectDatabase
         ).GetDirectory());
 }
Esempio n. 12
0
        private IEnumerable<string> GetPackRefs(FileRepository repository)
        {
            var packDir = repository.ObjectsDirectory.GetAbsolutePath();

            if (packDir == null)
            {
                return Enumerable.Empty<string>();
            }

            return new DirectoryInfo(packDir).GetFiles("*.pack").Select(x => x.Name).ToList();
        }
Esempio n. 13
0
 public RepoWrapper(FileRepository repository)
 {
     this.repository = repository;
 }
Esempio n. 14
0
			internal AlternateRepository(FileRepository r) : base(((ObjectDirectory)r.ObjectDatabase
				))
			{
				repository = r;
			}
Esempio n. 15
0
			public _ConfigChangedListener_163(FileRepository _enclosing)
			{
				this._enclosing = _enclosing;
			}
		public virtual void TestExceptionThrown_BareRepoGetWorkDir()
		{
			FilePath gitDir = GetFile("workdir");
			try
			{
				string s = new FileRepository(gitDir).WorkTree;
				NUnit.Framework.Assert.Fail("Expected NoWorkTreeException missing");
			}
			catch (NoWorkTreeException)
			{
			}
		}
Esempio n. 17
0
		async Task AddXwtFromGithubAsync (Solution solution, string newProjectName, bool createSubmodule, ProgressMonitor monitor)
		{
			try {
				var gitUrl = "https://github.com/" + (string.IsNullOrEmpty (Parameters ["XwtGithubRepository"]) ? Parameters ["XwtGithubRepository"] : "mono/xwt") + ".git";
				var gitBranch = Parameters ["XwtGithubBranch"];
				if (gitBranch == String.Empty)
					gitBranch = "master";
				var gitRepo = VersionControlService.GetRepository (solution) as GitRepository;
				var xwt_proj = solution.FindProjectByName ("Xwt") as DotNetProject;

				if (xwt_proj != null && xwt_proj.ItemId.ToUpper () != "{92494904-35FA-4DC9-BDE9-3A3E87AC49D3}") {
					xwt_proj = null;
					foreach (var item in solution.GetAllProjectsWithFlavor<DotNetProjectExtension>()) {
						if (item.ItemId.ToUpper () == "{92494904-35FA-4DC9-BDE9-3A3E87AC49D3}") {
							xwt_proj = item as DotNetProject;
							break;
						}
					}
				}

				var xwt_path = xwt_proj == null ? solution.BaseDirectory.Combine ("Xwt") : xwt_proj.BaseDirectory.ParentDirectory;

				monitor.BeginTask ("Configuring Xwt References...", 3);

				if (xwt_proj == null && !Directory.Exists (xwt_path)) {
					monitor.BeginTask ("Cloning Xwt into " + xwt_path + "...", 1);
					if (createSubmodule && gitRepo != null) {
						monitor.BeginTask ("Initializing Xwt submodule in " + xwt_path + "...", 1);

						var repo = new FileRepository (gitRepo.RootPath.Combine (".git"));
						var git = new Git (repo);

						try {
							using (var gm = new GitMonitor (monitor)) {
								var add_submodule = git.SubmoduleAdd ();
								add_submodule.SetPath ("Xwt");
								add_submodule.SetURI (gitUrl);
								add_submodule.SetProgressMonitor (gm);
								add_submodule.Call ();

								var submodule = new GitRepository (VersionControlService.GetVersionControlSystems ().First (id => id.Name == "Git"),
												   gitRepo.RootPath.Combine ("Xwt"), gitUrl);

								var submoduleRemote = submodule.GetCurrentRemote ();
								submodule.Fetch (monitor, submoduleRemote);
								if (submodule.GetCurrentBranch () != gitBranch) {
									submodule.CreateBranch (gitBranch, submoduleRemote + "/" + gitBranch, "refs/remotes/" + submoduleRemote + "/" + gitBranch);
									submodule.SwitchToBranch (monitor, gitBranch);
								}
							}
						} catch {
							Directory.Delete (xwt_path, true);
							throw;
						}

						monitor.EndTask ();
					} else {

						var repo = new GitRepository ();
						repo.Url = gitUrl;
						repo.Checkout (xwt_path, true, monitor);
						var remote = repo.GetCurrentRemote ();
						repo.Fetch (monitor, remote);
						if (repo.GetCurrentBranch () != gitBranch) {
							repo.CreateBranch (gitBranch, remote + "/" + gitBranch, "refs/remotes/" + remote + "/" + gitBranch);
							repo.SwitchToBranch (monitor, gitBranch);
						}
					}
					monitor.EndTask ();
				}

				SolutionFolder xwt_folder;
				if (xwt_proj != null)
					xwt_folder = xwt_proj.ParentFolder;
				else {
					xwt_folder = new SolutionFolder ();
					xwt_folder.Name = "Xwt";
				}
				solution.RootFolder.Items.Add (xwt_folder);
				monitor.Step (1);

				monitor.BeginTask ("Adding Xwt Projects to Solution...", 7);

				if (xwt_proj == null && File.Exists (xwt_path.Combine ("Xwt", "Xwt.csproj"))) {
					xwt_proj = await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt", "Xwt.csproj")
					) as DotNetProject;
				}
				if (xwt_proj == null)
					throw new InvalidOperationException ("Xwt project not found");

				monitor.Step (1);

				var xwt_gtk_proj = solution.FindProjectByName ("Xwt.Gtk") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Gtk", "Xwt.Gtk.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_gtk_win_proj = solution.FindProjectByName ("Xwt.Gtk.Windows") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Gtk.Windows", "Xwt.Gtk.Windows.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_gtk_mac_proj = solution.FindProjectByName ("Xwt.Gtk.Mac") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Gtk.Mac", "Xwt.Gtk.Mac.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_gtk3_proj = solution.FindProjectByName ("Xwt.Gtk3") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Gtk", "Xwt.Gtk3.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_wpf_proj = solution.FindProjectByName ("Xwt.WPF") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.WPF", "Xwt.WPF.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_mac_proj = solution.FindProjectByName ("Xwt.Mac") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Mac", "Xwt.Mac.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_xammac_proj = solution.FindProjectByName ("Xwt.XamMac") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.XamMac", "Xwt.XamMac.csproj")
					) as DotNetProject;


				monitor.EndTask ();
				monitor.Step (1);
				monitor.BeginTask ("Adding Xwt References...", solution.Items.Count);

				foreach (var item in solution.Items) {
					var project = item as DotNetProject;
					if (project != null) {
						if (project.Name == newProjectName ||
						    project.Name.StartsWith (newProjectName + ".", StringComparison.Ordinal))
							project.References.Add (ProjectReference.CreateProjectReference (xwt_proj));
						
						if (project.Name == newProjectName + ".Desktop") {
							if (Platform.IsWindows) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_wpf_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_win_proj));
							} else if (Platform.IsLinux) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk3_proj));
							} else if (Platform.IsMac) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_xammac_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_mac_proj));
							}
						}

						if (project.Name == newProjectName + ".Gtk2") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj));
							if (Platform.IsWindows) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_win_proj));
							} else if (Platform.IsMac) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_mac_proj));
							}
						}

						if (project.Name == newProjectName + ".Wpf") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_wpf_proj));
						}

						if (project.Name == newProjectName + ".Gtk3") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk3_proj));
						}

						if (project.Name == newProjectName + ".Mac") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_mac_proj));
						}

						if (project.Name == newProjectName + ".XamMac") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_xammac_proj));
						}
					}
					monitor.Step (1);
				}

				monitor.EndTask ();
				monitor.EndTask ();
				monitor.ReportSuccess ("Xwt Repository initialized successfully");

				await IdeApp.Workspace.SaveAsync (monitor);
			} catch (Exception e) {
				string msg = GettextCatalog.GetString ("Adding Xwt reference failed: ");
				monitor.ReportError (msg, e);
				MessageService.ShowError (msg, e);
			} finally {
				monitor.Dispose ();
			}
		}
Esempio n. 18
0
 /// <exception cref="System.IO.IOException"></exception>
 public static void DeleteTrashFile(FileRepository db, string name)
 {
     FilePath path = new FilePath(db.WorkTree, name);
     FileUtils.Delete(path);
 }
Esempio n. 19
0
        /// <exception cref="System.IO.IOException"></exception>
        public static FilePath WriteTrashFile(FileRepository db, string subdir, string name
			, string data)
        {
            FilePath path = new FilePath(db.WorkTree + "/" + subdir, name);
            Write(path, data);
            return path;
        }
Esempio n. 20
0
 /// <exception cref="System.IO.IOException"></exception>
 public static string Read(FileRepository db, string name)
 {
     FilePath file = new FilePath(db.WorkTree, name);
     return Read(file);
 }
Esempio n. 21
0
 public virtual void Test000_openrepo_alternate_index_file_and_objdirs()
 {
     FilePath repo1Parent = new FilePath(trash.GetParentFile(), "r1");
     FilePath indexFile = new FilePath(trash, "idx");
     FilePath objDir = new FilePath(trash, "../obj");
     FilePath altObjDir = ((ObjectDirectory)db.ObjectDatabase).GetDirectory();
     Repository repo1initial = new FileRepository(new FilePath(repo1Parent, Constants.
         DOT_GIT));
     repo1initial.Create();
     repo1initial.Close();
     FilePath theDir = new FilePath(repo1Parent, Constants.DOT_GIT);
     FileRepository r = new FileRepositoryBuilder().SetGitDir(theDir).SetObjectDirectory
         (objDir).AddAlternateObjectDirectory(altObjDir).SetIndexFile(indexFile).Build();
     //
     //
     //
     //
     AssertEqualsPath(theDir, r.Directory);
     AssertEqualsPath(theDir.GetParentFile(), r.WorkTree);
     AssertEqualsPath(indexFile, r.GetIndexFile());
     AssertEqualsPath(objDir, ((ObjectDirectory)r.ObjectDatabase).GetDirectory());
     NUnit.Framework.Assert.IsNotNull(r.Open(ObjectId.FromString("6db9c2ebf75590eef973081736730a9ea169a0c4"
         )));
     // Must close or the default repo pack files created by this test gets
     // locked via the alternate object directories on Windows.
     r.Close();
 }
Esempio n. 22
0
			public _RefWriter_495(TestRepository<R> _enclosing, FileRepository fr, ICollection
				<Ref> baseArg1) : base(baseArg1)
			{
				this._enclosing = _enclosing;
				this.fr = fr;
			}
Esempio n. 23
0
		public virtual void TestRenameBranchAlsoInPack()
		{
			ObjectId rb = db.Resolve("refs/heads/b");
			ObjectId rb2 = db.Resolve("refs/heads/b~1");
			NUnit.Framework.Assert.AreEqual(RefStorage.PACKED, db.GetRef("refs/heads/b").GetStorage
				());
			RefUpdate updateRef = db.UpdateRef("refs/heads/b");
			updateRef.SetNewObjectId(rb2);
			updateRef.SetForceUpdate(true);
			RefUpdate.Result update = updateRef.Update();
			NUnit.Framework.Assert.AreEqual(RefUpdate.Result.FORCED, update, "internal check new ref is loose"
				);
			NUnit.Framework.Assert.AreEqual(RefStorage.LOOSE, db.GetRef("refs/heads/b").GetStorage
				());
			WriteReflog(db, rb, "Just a message", "refs/heads/b");
			NUnit.Framework.Assert.IsTrue(new FilePath(db.Directory, "logs/refs/heads/b").Exists
				(), "log on old branch");
			RefRename renameRef = db.RenameRef("refs/heads/b", "refs/heads/new/name");
			RefUpdate.Result result = renameRef.Rename();
			NUnit.Framework.Assert.AreEqual(RefUpdate.Result.RENAMED, result);
			NUnit.Framework.Assert.AreEqual(rb2, db.Resolve("refs/heads/new/name"));
			NUnit.Framework.Assert.IsNull(db.Resolve("refs/heads/b"));
			NUnit.Framework.Assert.AreEqual("Branch: renamed b to new/name", db.GetReflogReader
				("new/name").GetLastEntry().GetComment());
			NUnit.Framework.Assert.AreEqual(3, db.GetReflogReader("refs/heads/new/name").GetReverseEntries
				().Count);
			NUnit.Framework.Assert.AreEqual("Branch: renamed b to new/name", db.GetReflogReader
				("refs/heads/new/name").GetReverseEntries()[0].GetComment());
			NUnit.Framework.Assert.AreEqual(0, db.GetReflogReader("HEAD").GetReverseEntries()
				.Count);
			// make sure b's log file is gone too.
			NUnit.Framework.Assert.IsFalse(new FilePath(db.Directory, "logs/refs/heads/b").Exists
				());
			// Create new Repository instance, to reread caches and make sure our
			// assumptions are persistent.
			Repository ndb = new FileRepository(db.Directory);
			NUnit.Framework.Assert.AreEqual(rb2, ndb.Resolve("refs/heads/new/name"));
			NUnit.Framework.Assert.IsNull(ndb.Resolve("refs/heads/b"));
		}
		public override void Setup() {
			base.Setup();
			DirectoryInfo gitDir = new DirectoryInfo (PROJECT_ROOT + ".git");
			repo = new FileRepository (gitDir.FullName);
			walker = new RevWalk (repo);
		}
Esempio n. 25
0
		public override void SetUp()
		{
			base.SetUp();
			db = CreateWorkRepository();
			trash = db.WorkTree;
		}
Esempio n. 26
0
 /// <exception cref="NGit.Errors.TransportException"></exception>
 public InternalLocalFetchConnection(TransportLocal _enclosing)
     : base(_enclosing)
 {
     this._enclosing = _enclosing;
     Repository dst;
     try
     {
         dst = new FileRepository(this._enclosing.remoteGitDir);
     }
     catch (IOException)
     {
         throw new TransportException(this.uri, JGitText.Get().notAGitDirectory);
     }
     PipedInputStream in_r;
     PipedOutputStream in_w;
     PipedInputStream out_r;
     PipedOutputStream out_w;
     try
     {
         in_r = new PipedInputStream();
         in_w = new PipedOutputStream(in_r);
         out_r = new _PipedInputStream_218();
         // The client (BasePackFetchConnection) can write
         // a huge burst before it reads again. We need to
         // force the buffer to be big enough, otherwise it
         // will deadlock both threads.
         out_w = new PipedOutputStream(out_r);
     }
     catch (IOException err)
     {
         dst.Close();
         throw new TransportException(this.uri, JGitText.Get().cannotConnectPipes, err);
     }
     this.worker = new _Thread_233(this, dst, out_r, in_w, "JGit-Upload-Pack");
     // Client side of the pipes should report the problem.
     // Clients side will notice we went away, and report.
     // Ignore close failure, we probably crashed above.
     // Ignore close failure, we probably crashed above.
     this.worker.Start();
     this.Init(in_r, out_w);
     this.ReadAdvertisedRefs();
 }
Esempio n. 27
0
        private void WriteInfoPacks(IEnumerable<string> packs, FileRepository repository)
        {
            var w = new StringBuilder();

            foreach (string pack in packs)
            {
                w.Append("P ");
                w.Append(pack);
                w.Append('\n');
            }

            var infoPacksPath = Path.Combine(repository.ObjectsDirectory.GetAbsolutePath(), "info/packs");
            var encoded = Encoding.ASCII.GetBytes(w.ToString());

            using (Stream fs = File.Create(infoPacksPath))
            {
                fs.Write(encoded, 0, encoded.Length);
            }
        }
Esempio n. 28
0
 /// <exception cref="NGit.Errors.TransportException"></exception>
 public InternalLocalPushConnection(TransportLocal _enclosing)
     : base(_enclosing)
 {
     this._enclosing = _enclosing;
     Repository dst;
     try
     {
         dst = new FileRepository(this._enclosing.remoteGitDir);
     }
     catch (IOException)
     {
         throw new TransportException(this.uri, JGitText.Get().notAGitDirectory);
     }
     PipedInputStream in_r;
     PipedOutputStream in_w;
     PipedInputStream out_r;
     PipedOutputStream out_w;
     try
     {
         in_r = new PipedInputStream();
         in_w = new PipedOutputStream(in_r);
         out_r = new PipedInputStream();
         out_w = new PipedOutputStream(out_r);
     }
     catch (IOException err)
     {
         dst.Close();
         throw new TransportException(this.uri, JGitText.Get().cannotConnectPipes, err);
     }
     this.worker = new _Thread_365(this, dst, out_r, in_w, "JGit-Receive-Pack");
     // Client side of the pipes should report the problem.
     // Clients side will notice we went away, and report.
     // Ignore close failure, we probably crashed above.
     // Ignore close failure, we probably crashed above.
     this.worker.Start();
     this.Init(in_r, out_w);
     this.ReadAdvertisedRefs();
 }
 public static void Init(string folderName)
 {
     if (GitBash.Exists)
     {
         GitBash.Run("init", folderName);
         GitBash.Run("config core.ignorecase true", folderName);
     }
     else
     {
         var gitFolder = Path.Combine(folderName, Constants.DOT_GIT);
         var repo = new FileRepository(gitFolder);
         repo.Create();
         var dir = Directory.CreateDirectory(gitFolder);
         dir.Attributes = FileAttributes.Directory | FileAttributes.Hidden;
     }
 }
Esempio n. 30
0
        /// <summary>
        /// httpプロトコルバッファ値を設定。
        /// この設定がないと大きなファイルをpushできない。
        /// </summary>
        /// <param name="folderPath">リポジトリパス</param>
        private void SettingHttpBufferSize(string folderPath)
        {
            FilePath path = new FilePath(folderPath, @".git");

            FileRepository db = new FileRepository(path);

            Git git = new Git(db);

            var config = git.GetRepository().GetConfig();

            config.SetString("http", null, "postBuffer", "524288000");
            config.Save();
        }