本文整理汇总了C#中NGit.Transport.RemoteConfig.AddURI方法的典型用法代码示例。如果您正苦于以下问题:C# RemoteConfig.AddURI方法的具体用法?C# RemoteConfig.AddURI怎么用?C# RemoteConfig.AddURI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NGit.Transport.RemoteConfig
的用法示例。
在下文中一共展示了RemoteConfig.AddURI方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: SetUp
public override void SetUp()
{
base.SetUp();
Config config = ((FileBasedConfig)db.GetConfig());
remoteConfig = new RemoteConfig(config, "test");
remoteConfig.AddURI(new URIish("http://everyones.loves.git/u/2"));
transport = null;
}
示例3: 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()));
}
示例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: 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;
}
示例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: 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");
}
示例8: TestRemoveOnlyURI
public virtual void TestRemoveOnlyURI()
{
ReadConfig(string.Empty);
URIish a = new URIish("/some/dir");
RemoteConfig rc = new RemoteConfig(config, "backup");
NUnit.Framework.Assert.IsTrue(rc.AddURI(a));
NUnit.Framework.Assert.AreEqual(1, rc.URIs.Count);
NUnit.Framework.Assert.AreSame(a, rc.URIs[0]);
NUnit.Framework.Assert.IsTrue(rc.RemoveURI(a));
NUnit.Framework.Assert.AreEqual(0, rc.URIs.Count);
}
示例9: TestSaveAddURI
public virtual void TestSaveAddURI()
{
ReadConfig("[remote \"spearce\"]\n" + "url = http://www.spearce.org/egit.git\n" +
"fetch = +refs/heads/*:refs/remotes/spearce/*\n");
RemoteConfig rc = new RemoteConfig(config, "spearce");
rc.AddURI(new URIish("/some/dir"));
NUnit.Framework.Assert.AreEqual(2, rc.URIs.Count);
rc.Update(config);
CheckConfig("[remote \"spearce\"]\n" + "\turl = http://www.spearce.org/egit.git\n"
+ "\turl = /some/dir\n" + "\tfetch = +refs/heads/*:refs/remotes/spearce/*\n");
}
示例10: TestAddURI
public virtual void TestAddURI()
{
ReadConfig(string.Empty);
URIish uri = new URIish("/some/dir");
RemoteConfig rc = new RemoteConfig(config, "backup");
NUnit.Framework.Assert.AreEqual(0, rc.URIs.Count);
NUnit.Framework.Assert.IsTrue(rc.AddURI(uri));
NUnit.Framework.Assert.AreEqual(1, rc.URIs.Count);
NUnit.Framework.Assert.AreSame(uri, rc.URIs[0]);
NUnit.Framework.Assert.IsFalse(rc.AddURI(new URIish(uri.ToString())));
NUnit.Framework.Assert.AreEqual(1, rc.URIs.Count);
}
示例11: TestRemoveLastURI
public virtual void TestRemoveLastURI()
{
ReadConfig(string.Empty);
URIish a = new URIish("/some/dir");
URIish b = new URIish("/another/dir");
URIish c = new URIish("/more/dirs");
RemoteConfig rc = new RemoteConfig(config, "backup");
NUnit.Framework.Assert.IsTrue(rc.AddURI(a));
NUnit.Framework.Assert.IsTrue(rc.AddURI(b));
NUnit.Framework.Assert.IsTrue(rc.AddURI(c));
NUnit.Framework.Assert.AreEqual(3, rc.URIs.Count);
NUnit.Framework.Assert.AreSame(a, rc.URIs[0]);
NUnit.Framework.Assert.AreSame(b, rc.URIs[1]);
NUnit.Framework.Assert.AreSame(c, rc.URIs[2]);
NUnit.Framework.Assert.IsTrue(rc.RemoveURI(c));
NUnit.Framework.Assert.AreEqual(2, rc.URIs.Count);
NUnit.Framework.Assert.AreSame(a, rc.URIs[0]);
NUnit.Framework.Assert.AreSame(b, rc.URIs[1]);
}
示例12: 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));
}
示例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;
}
示例14: 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));
}
示例15: 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"
));
}