public override void CopyConfigurationFrom (Repository other) { base.CopyConfigurationFrom (other); GitRepository r = (GitRepository)other; RootPath = r.RootPath; if (!RootPath.IsNullOrEmpty) RootRepository = new LocalGitRepository (RootPath); }
public GitRepository (FilePath path, string url) { RootPath = path; RootRepository = new LocalGitRepository (path.Combine (Constants.DOT_GIT)); Url = url; }
public static LocalGitRepository Init (string targetLocalPath, string url, IProgressMonitor monitor) { 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; }
public GitRepository (FilePath path, string url) { this.path = path; Url = url; repo = new LocalGitRepository (path.Combine (Constants.DOT_GIT)); }
public override Repository Publish (string serverPath, FilePath localPath, FilePath[] files, string message, IProgressMonitor monitor) { // Initialize the repository repo = GitUtil.Init (localPath, Url, monitor); path = localPath; // Add the project files ChangeSet cs = CreateChangeSet (localPath); NGit.Api.Git git = new NGit.Api.Git (repo); var cmd = git.Add (); foreach (FilePath fp in files) { cmd.AddFilepattern (ToGitPath (fp)); cs.AddFile (fp); } cmd.Call (); // Create the initial commit cs.GlobalComment = message; Commit (cs, monitor); // Push to remote repo Push (monitor, "origin", "master"); return this; }
public override void CopyConfigurationFrom (Repository other) { base.CopyConfigurationFrom (other); GitRepository r = (GitRepository)other; path = r.path; if (r.repo != null) repo = new LocalGitRepository (path); }
public override Repository Publish (string serverPath, FilePath localPath, FilePath[] files, string message, IProgressMonitor monitor) { // Initialize the repository repo = GitUtil.Init (localPath, Url, monitor); NGit.Api.Git git = new NGit.Api.Git (repo); try { var refs = git.Fetch ().Call ().GetAdvertisedRefs (); if (refs.Count > 0) { throw new UserException ("The remote repository already contains branches. MonoDevelop can only publish to an empty repository"); } } catch { if (Directory.Exists (repo.Directory)) Directory.Delete (repo.Directory, true); repo.Close (); repo = null; throw; } path = localPath; // Add the project files ChangeSet cs = CreateChangeSet (localPath); var cmd = git.Add (); foreach (FilePath fp in files) { cmd.AddFilepattern (ToGitPath (fp)); cs.AddFile (fp); } cmd.Call (); // Create the initial commit cs.GlobalComment = message; Commit (cs, monitor); // Push to remote repo Push (monitor, "origin", "master"); return this; }