コード例 #1
0
		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";
		}
コード例 #2
0
        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";
        }
コード例 #3
0
        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";
        }
コード例 #4
0
ファイル: GitUtil.cs プロジェクト: zendbit/monodevelop
        public static LocalGitRepository Init(string targetLocalPath, string url)
        {
            InitCommand ci = new InitCommand();

            ci.SetDirectory(targetLocalPath);
            ci.Call();
            LocalGitRepository repo = new LocalGitRepository(Path.Combine(targetLocalPath, Constants.DOT_GIT));

            string branch = Constants.R_HEADS + "master";

            RefUpdate head = repo.UpdateRef(Constants.HEAD);

            head.DisableRefLog();
            head.Link(branch);

            if (url != null)
            {
                RemoteConfig remoteConfig = new RemoteConfig(repo.GetConfig(), "origin");
                remoteConfig.AddURI(new URIish(url));

                string  dst  = Constants.R_REMOTES + remoteConfig.Name;
                RefSpec wcrs = new RefSpec();
                wcrs = wcrs.SetForceUpdate(true);
                wcrs = wcrs.SetSourceDestination(Constants.R_HEADS + "*", dst + "/*");

                remoteConfig.AddFetchRefSpec(wcrs);
                remoteConfig.Update(repo.GetConfig());
            }

            // we're setting up for a clone with a checkout
            repo.GetConfig().SetBoolean("core", null, "bare", false);

            repo.GetConfig().Save();
            return(repo);
        }
コード例 #5
0
		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";
		}
コード例 #6
0
ファイル: InitCommandTest.cs プロジェクト: LunarLanding/ngit
		public virtual void TestInitRepository()
		{
			FilePath directory = CreateTempDirectory("testInitRepository");
			InitCommand command = new InitCommand();
			command.SetDirectory(directory);
			Repository repository = command.Call().GetRepository();
			AddRepoToClose(repository);
			NUnit.Framework.Assert.IsNotNull(repository);
		}
コード例 #7
0
ファイル: GitUtil.cs プロジェクト: stewartwhaley/monodevelop
		public static FileRepository Init (string targetLocalPath, string url, IProgressMonitor monitor)
		{
			InitCommand ci = new InitCommand ();
			ci.SetDirectory (targetLocalPath);
			var git = ci.Call ();
			FileRepository repo = (FileRepository) git.GetRepository ();
			
			string branch = Constants.R_HEADS + "master";
			
			RefUpdate head = repo.UpdateRef (Constants.HEAD);
			head.DisableRefLog ();
			head.Link (branch);
			
			RemoteConfig remoteConfig = new RemoteConfig (repo.GetConfig (), "origin");
			remoteConfig.AddURI (new URIish (url));
			
			string dst = Constants.R_REMOTES + remoteConfig.Name;
			RefSpec wcrs = new RefSpec();
			wcrs = wcrs.SetForceUpdate (true);
			wcrs = wcrs.SetSourceDestination (Constants.R_HEADS	+ "*", dst + "/*");
			
			remoteConfig.AddFetchRefSpec (wcrs);
	
			// we're setting up for a clone with a checkout
			repo.GetConfig().SetBoolean ("core", null, "bare", false);
	
			remoteConfig.Update (repo.GetConfig());
	
			repo.GetConfig().Save();
			return repo;
		}
コード例 #8
0
ファイル: InitCommandTest.cs プロジェクト: LunarLanding/ngit
		public virtual void TestInitNonEmptyRepository()
		{
			FilePath directory = CreateTempDirectory("testInitRepository2");
			FilePath someFile = new FilePath(directory, "someFile");
			someFile.CreateNewFile();
			NUnit.Framework.Assert.IsTrue(someFile.Exists());
			NUnit.Framework.Assert.IsTrue(directory.ListFiles().Length > 0);
			InitCommand command = new InitCommand();
			command.SetDirectory(directory);
			Repository repository = command.Call().GetRepository();
			AddRepoToClose(repository);
			NUnit.Framework.Assert.IsNotNull(repository);
		}
コード例 #9
0
ファイル: GitUtil.cs プロジェクト: joaonunesk/monodevelop
		public static FileRepository Clone (string targetLocalPath, string url, IProgressMonitor monitor)
		{
			// Initialize
			
			InitCommand ci = new InitCommand ();
			ci.SetDirectory (targetLocalPath);
			var git = ci.Call ();
			FileRepository repo = (FileRepository) git.GetRepository ();
			
			string branch = Constants.R_HEADS + "master";
			string remoteName = "origin";
			
			RefUpdate head = repo.UpdateRef (Constants.HEAD);
			head.DisableRefLog ();
			head.Link (branch);
			
			RemoteConfig remoteConfig = new RemoteConfig (repo.GetConfig (), remoteName);
			remoteConfig.AddURI (new URIish (url));
			
			string dst = Constants.R_REMOTES + remoteConfig.Name;
			RefSpec wcrs = new RefSpec();
			wcrs = wcrs.SetForceUpdate (true);
			wcrs = wcrs.SetSourceDestination (Constants.R_HEADS	+ "*", dst + "/*");
			
			remoteConfig.AddFetchRefSpec (wcrs);
	
			// we're setting up for a clone with a checkout
			repo.GetConfig().SetBoolean ("core", null, "bare", false);
	
			remoteConfig.Update (repo.GetConfig());
	
			repo.GetConfig().Save();
			
			// Fetch
			
			Transport tn = Transport.Open (repo, remoteName);
			FetchResult r;

			try {
				r = tn.Fetch(new GitMonitor (monitor), null);
			}
			finally {
				tn.Close ();
			}
			
			// Create the master branch
			
			// branch is like 'Constants.R_HEADS + branchName', we need only
			// the 'branchName' part
			String branchName = branch.Substring (Constants.R_HEADS.Length);
			git.BranchCreate ().SetName (branchName).SetUpstreamMode (CreateBranchCommand.SetupUpstreamMode.TRACK).SetStartPoint ("origin/master").Call ();
			
			// Checkout

			DirCache dc = repo.LockDirCache ();
			try {
				RevWalk rw = new RevWalk (repo);
				ObjectId remCommitId = repo.Resolve (remoteName + "/" + branchName);
				RevCommit remCommit = rw.ParseCommit (remCommitId);
				DirCacheCheckout co = new DirCacheCheckout (repo, null, dc, remCommit.Tree);
				co.Checkout ();
			} catch {
				dc.Unlock ();
				throw;
			}
			
			return repo;
		}
コード例 #10
0
ファイル: InitCommandTest.cs プロジェクト: shoff/ngit
		public virtual void TestInitBareRepository()
		{
			try
			{
				FilePath directory = CreateTempDirectory("testInitBareRepository");
				InitCommand command = new InitCommand();
				command.SetDirectory(directory);
				command.SetBare(true);
				Repository repository = command.Call().GetRepository();
				AddRepoToClose(repository);
				NUnit.Framework.Assert.IsNotNull(repository);
				NUnit.Framework.Assert.IsTrue(repository.IsBare);
			}
			catch (Exception e)
			{
				NUnit.Framework.Assert.Fail(e.Message);
			}
		}