本文整理汇总了C#中NGit.Transport.RemoteConfig.Update方法的典型用法代码示例。如果您正苦于以下问题:C# RemoteConfig.Update方法的具体用法?C# RemoteConfig.Update怎么用?C# RemoteConfig.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NGit.Transport.RemoteConfig
的用法示例。
在下文中一共展示了RemoteConfig.Update方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestPush
public virtual void TestPush()
{
// create other repository
Repository db2 = CreateWorkRepository();
// setup the first repository
StoredConfig config = ((FileBasedConfig)db.GetConfig());
RemoteConfig remoteConfig = new RemoteConfig(config, "test");
URIish uri = new URIish(db2.Directory.ToURI().ToURL());
remoteConfig.AddURI(uri);
remoteConfig.Update(config);
config.Save();
Git git1 = new Git(db);
// create some refs via commits and tag
RevCommit commit = git1.Commit().SetMessage("initial commit").Call();
Ref tagRef = git1.Tag().SetName("tag").Call();
try
{
db2.Resolve(commit.Id.GetName() + "^{commit}");
NUnit.Framework.Assert.Fail("id shouldn't exist yet");
}
catch (MissingObjectException)
{
}
// we should get here
RefSpec spec = new RefSpec("refs/heads/master:refs/heads/x");
git1.Push().SetRemote("test").SetRefSpecs(spec).Call();
NUnit.Framework.Assert.AreEqual(commit.Id, db2.Resolve(commit.Id.GetName() + "^{commit}"
));
NUnit.Framework.Assert.AreEqual(tagRef.GetObjectId(), db2.Resolve(tagRef.GetObjectId
().GetName()));
}
示例2: TestFetch
public virtual void TestFetch()
{
// create other repository
Repository db2 = CreateWorkRepository();
Git git2 = new Git(db2);
// setup the first repository to fetch from the second repository
StoredConfig config = ((FileBasedConfig)db.GetConfig());
RemoteConfig remoteConfig = new RemoteConfig(config, "test");
URIish uri = new URIish(db2.Directory.ToURI().ToURL());
remoteConfig.AddURI(uri);
remoteConfig.Update(config);
config.Save();
// create some refs via commits and tag
RevCommit commit = git2.Commit().SetMessage("initial commit").Call();
RevTag tag = git2.Tag().SetName("tag").Call();
Git git1 = new Git(db);
RefSpec spec = new RefSpec("refs/heads/master:refs/heads/x");
git1.Fetch().SetRemote("test").SetRefSpecs(spec).Call();
NUnit.Framework.Assert.AreEqual(commit.Id, db.Resolve(commit.Id.GetName() + "^{commit}"
));
NUnit.Framework.Assert.AreEqual(tag.Id, db.Resolve(tag.Id.GetName()));
}
示例3: Init
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;
}
示例4: SetUp
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");
}
示例5: TestSaveTimeout
public virtual void TestSaveTimeout()
{
RemoteConfig rc = new RemoteConfig(config, "origin");
rc.AddURI(new URIish("/some/dir"));
rc.AddFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/" + rc.Name + "/*"));
rc.Timeout = 60;
rc.Update(config);
CheckConfig("[remote \"origin\"]\n" + "\turl = /some/dir\n" + "\tfetch = +refs/heads/*:refs/remotes/origin/*\n"
+ "\ttimeout = 60\n");
}
示例6: TestSaveAllTags
public virtual void TestSaveAllTags()
{
RemoteConfig rc = new RemoteConfig(config, "origin");
rc.AddURI(new URIish("/some/dir"));
rc.AddFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/" + rc.Name + "/*"));
rc.TagOpt = TagOpt.FETCH_TAGS;
rc.Update(config);
CheckConfig("[remote \"origin\"]\n" + "\turl = /some/dir\n" + "\tfetch = +refs/heads/*:refs/remotes/origin/*\n"
+ "\ttagopt = --tags\n");
}
示例7: TestSaveRemoveFirstURI
public virtual void TestSaveRemoveFirstURI()
{
ReadConfig("[remote \"spearce\"]\n" + "url = http://www.spearce.org/egit.git\n" +
"url = /some/dir\n" + "fetch = +refs/heads/*:refs/remotes/spearce/*\n");
RemoteConfig rc = new RemoteConfig(config, "spearce");
NUnit.Framework.Assert.AreEqual(2, rc.URIs.Count);
rc.RemoveURI(new URIish("http://www.spearce.org/egit.git"));
NUnit.Framework.Assert.AreEqual(1, rc.URIs.Count);
rc.Update(config);
CheckConfig("[remote \"spearce\"]\n" + "\turl = /some/dir\n" + "\tfetch = +refs/heads/*:refs/remotes/spearce/*\n"
);
}
示例8: TestTrackingUpdate
public virtual void TestTrackingUpdate()
{
Repository db2 = CreateBareRepository();
string remote = "origin";
string branch = "refs/heads/master";
string trackingBranch = "refs/remotes/" + remote + "/master";
Git git = new Git(db);
RevCommit commit1 = git.Commit().SetMessage("Initial commit").Call();
RefUpdate branchRefUpdate = db.UpdateRef(branch);
branchRefUpdate.SetNewObjectId(commit1.Id);
branchRefUpdate.Update();
RefUpdate trackingBranchRefUpdate = db.UpdateRef(trackingBranch);
trackingBranchRefUpdate.SetNewObjectId(commit1.Id);
trackingBranchRefUpdate.Update();
StoredConfig config = ((FileBasedConfig)db.GetConfig());
RemoteConfig remoteConfig = new RemoteConfig(config, remote);
URIish uri = new URIish(db2.Directory.ToURI().ToURL());
remoteConfig.AddURI(uri);
remoteConfig.AddFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/" + remote +
"/*"));
remoteConfig.Update(config);
config.Save();
RevCommit commit2 = git.Commit().SetMessage("Commit to push").Call();
RefSpec spec = new RefSpec(branch + ":" + branch);
Iterable<PushResult> resultIterable = git.Push().SetRemote(remote).SetRefSpecs(spec
).Call();
PushResult result = resultIterable.Iterator().Next();
TrackingRefUpdate trackingRefUpdate = result.GetTrackingRefUpdate(trackingBranch);
NUnit.Framework.Assert.IsNotNull(trackingRefUpdate);
NUnit.Framework.Assert.AreEqual(trackingBranch, trackingRefUpdate.GetLocalName());
NUnit.Framework.Assert.AreEqual(branch, trackingRefUpdate.GetRemoteName());
NUnit.Framework.Assert.AreEqual(commit2.Id, trackingRefUpdate.GetNewObjectId());
NUnit.Framework.Assert.AreEqual(commit2.Id, db.Resolve(trackingBranch));
NUnit.Framework.Assert.AreEqual(commit2.Id, db2.Resolve(branch));
}
示例9: TestPushWithoutPushRefSpec
public virtual void TestPushWithoutPushRefSpec()
{
Git git = new Git(db);
Git git2 = new Git(CreateBareRepository());
StoredConfig config = git.GetRepository().GetConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "test");
URIish uri = new URIish(git2.GetRepository().Directory.ToURI().ToURL());
remoteConfig.AddURI(uri);
remoteConfig.AddFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
remoteConfig.Update(config);
config.Save();
WriteTrashFile("f", "content of f");
git.Add().AddFilepattern("f").Call();
RevCommit commit = git.Commit().SetMessage("adding f").Call();
git.Checkout().SetName("not-pushed").SetCreateBranch(true).Call();
git.Checkout().SetName("branchtopush").SetCreateBranch(true).Call();
NUnit.Framework.Assert.AreEqual(null, git2.GetRepository().Resolve("refs/heads/branchtopush"
));
NUnit.Framework.Assert.AreEqual(null, git2.GetRepository().Resolve("refs/heads/not-pushed"
));
NUnit.Framework.Assert.AreEqual(null, git2.GetRepository().Resolve("refs/heads/master"
));
git.Push().SetRemote("test").Call();
NUnit.Framework.Assert.AreEqual(commit.Id, git2.GetRepository().Resolve("refs/heads/branchtopush"
));
NUnit.Framework.Assert.AreEqual(null, git2.GetRepository().Resolve("refs/heads/not-pushed"
));
NUnit.Framework.Assert.AreEqual(null, git2.GetRepository().Resolve("refs/heads/master"
));
}
示例10: TestPushRefUpdate
public virtual void TestPushRefUpdate()
{
Git git = new Git(db);
Git git2 = new Git(CreateBareRepository());
StoredConfig config = git.GetRepository().GetConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "test");
URIish uri = new URIish(git2.GetRepository().Directory.ToURI().ToURL());
remoteConfig.AddURI(uri);
remoteConfig.AddPushRefSpec(new RefSpec("+refs/heads/*:refs/heads/*"));
remoteConfig.Update(config);
config.Save();
WriteTrashFile("f", "content of f");
git.Add().AddFilepattern("f").Call();
RevCommit commit = git.Commit().SetMessage("adding f").Call();
NUnit.Framework.Assert.AreEqual(null, git2.GetRepository().Resolve("refs/heads/master"
));
git.Push().SetRemote("test").Call();
NUnit.Framework.Assert.AreEqual(commit.Id, git2.GetRepository().Resolve("refs/heads/master"
));
git.BranchCreate().SetName("refs/heads/test").Call();
git.Checkout().SetName("refs/heads/test").Call();
for (int i = 0; i < 6; i++)
{
WriteTrashFile("f" + i, "content of f" + i);
git.Add().AddFilepattern("f" + i).Call();
commit = git.Commit().SetMessage("adding f" + i).Call();
git.Push().SetRemote("test").Call();
git2.GetRepository().GetAllRefs();
NUnit.Framework.Assert.AreEqual(commit.Id, git2.GetRepository().Resolve("refs/heads/test"
), "failed to update on attempt " + i);
}
}
示例11: Clone
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;
}
示例12: TestCheckoutRemoteTrackingWithoutLocalBranch
public virtual void TestCheckoutRemoteTrackingWithoutLocalBranch()
{
// create second repository
Repository db2 = CreateWorkRepository();
Git git2 = new Git(db2);
// setup the second repository to fetch from the first repository
StoredConfig config = db2.GetConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
URIish uri = new URIish(db.Directory.ToURI().ToURL());
remoteConfig.AddURI(uri);
remoteConfig.Update(config);
config.Save();
// fetch from first repository
RefSpec spec = new RefSpec("+refs/heads/*:refs/remotes/origin/*");
git2.Fetch().SetRemote("origin").SetRefSpecs(spec).Call();
// checkout remote tracking branch in second repository
// (no local branches exist yet in second repository)
git2.Checkout().SetName("remotes/origin/test").Call();
NUnit.Framework.Assert.AreEqual("[Test.txt, mode:100644, content:Some change]", IndexState
(db2, CONTENT));
}
示例13: SetUpRepoWithRemote
/// <exception cref="System.Exception"></exception>
private Git SetUpRepoWithRemote()
{
Repository remoteRepository = CreateWorkRepository();
Git remoteGit = new Git(remoteRepository);
// commit something
WriteTrashFile("Test.txt", "Hello world");
remoteGit.Add().AddFilepattern("Test.txt").Call();
initialCommit = remoteGit.Commit().SetMessage("Initial commit").Call();
WriteTrashFile("Test.txt", "Some change");
remoteGit.Add().AddFilepattern("Test.txt").Call();
secondCommit = remoteGit.Commit().SetMessage("Second commit").Call();
// create a master branch
RefUpdate rup = remoteRepository.UpdateRef("refs/heads/master");
rup.SetNewObjectId(initialCommit.Id);
rup.ForceUpdate();
Repository localRepository = CreateWorkRepository();
Git localGit = new Git(localRepository);
StoredConfig config = localRepository.GetConfig();
RemoteConfig rc = new RemoteConfig(config, "origin");
rc.AddURI(new URIish(remoteRepository.Directory.GetPath()));
rc.AddFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
rc.Update(config);
config.Save();
FetchResult res = localGit.Fetch().SetRemote("origin").Call();
NUnit.Framework.Assert.IsFalse(res.GetTrackingRefUpdates().IsEmpty());
rup = localRepository.UpdateRef("refs/heads/master");
rup.SetNewObjectId(initialCommit.Id);
rup.ForceUpdate();
rup = localRepository.UpdateRef(Constants.HEAD);
rup.Link("refs/heads/master");
rup.SetNewObjectId(initialCommit.Id);
rup.Update();
return localGit;
}