本文整理汇总了C#中MonoDevelop.VersionControl.Git.GitRepository.SwitchToBranch方法的典型用法代码示例。如果您正苦于以下问题:C# GitRepository.SwitchToBranch方法的具体用法?C# GitRepository.SwitchToBranch怎么用?C# GitRepository.SwitchToBranch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoDevelop.VersionControl.Git.GitRepository
的用法示例。
在下文中一共展示了GitRepository.SwitchToBranch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SwitchToBranch
public static void SwitchToBranch (GitRepository repo, string branch)
{
IdeApp.Workbench.AutoReloadDocuments = true;
try {
repo.SwitchToBranch (branch);
} finally {
IdeApp.Workbench.AutoReloadDocuments = false;
}
}
示例2: SwitchToBranch
public static void SwitchToBranch (GitRepository repo, string branch)
{
MessageDialogProgressMonitor monitor = new MessageDialogProgressMonitor (true, false, false, true);
try {
IdeApp.Workbench.AutoReloadDocuments = true;
IdeApp.Workbench.LockGui ();
System.Threading.ThreadPool.QueueUserWorkItem (delegate {
try {
repo.SwitchToBranch (monitor, branch);
} catch (Exception ex) {
monitor.ReportError ("Branch switch failed", ex);
} finally {
monitor.Dispose ();
}
});
monitor.AsyncOperation.WaitForCompleted ();
} finally {
IdeApp.Workbench.AutoReloadDocuments = false;
IdeApp.Workbench.UnlockGui ();
}
}
示例3: SwitchToBranch
public async static Task<bool> SwitchToBranch (GitRepository repo, string branch)
{
var monitor = new MessageDialogProgressMonitor (true, false, false, true);
try {
IdeApp.Workbench.AutoReloadDocuments = true;
IdeApp.Workbench.LockGui ();
var t = await Task.Run (delegate {
try {
return repo.SwitchToBranch (monitor, branch);
} catch (Exception ex) {
monitor.ReportError (GettextCatalog.GetString ("Branch switch failed"), ex);
return false;
} finally {
monitor.Dispose ();
}
});
return t;
} finally {
IdeApp.Workbench.AutoReloadDocuments = false;
IdeApp.Workbench.UnlockGui ();
}
}
示例4: AddXwtFromGithubAsync
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;
//.........这里部分代码省略.........
示例5: SwitchToBranch
public static void SwitchToBranch (GitRepository repo, string branch)
{
var monitor = new MessageDialogProgressMonitor (true, false, false, true);
try {
IdeApp.Workbench.AutoReloadDocuments = true;
IdeApp.Workbench.LockGui ();
Task.Run (delegate {
try {
repo.SwitchToBranch (monitor, branch);
} catch (Exception ex) {
monitor.ReportError ("Branch switch failed", ex);
} finally {
monitor.Dispose ();
}
}).Wait ();
} finally {
IdeApp.Workbench.AutoReloadDocuments = false;
IdeApp.Workbench.UnlockGui ();
}
}