本文整理汇总了C#中NGit.Transport.RemoteConfig类的典型用法代码示例。如果您正苦于以下问题:C# RemoteConfig类的具体用法?C# RemoteConfig怎么用?C# RemoteConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RemoteConfig类属于NGit.Transport命名空间,在下文中一共展示了RemoteConfig类的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: TestSimple
public virtual void TestSimple()
{
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");
IList<URIish> allURIs = rc.URIs;
RefSpec spec;
NUnit.Framework.Assert.AreEqual("spearce", rc.Name);
NUnit.Framework.Assert.IsNotNull(allURIs);
NUnit.Framework.Assert.IsNotNull(rc.FetchRefSpecs);
NUnit.Framework.Assert.IsNotNull(rc.PushRefSpecs);
NUnit.Framework.Assert.IsNotNull(rc.TagOpt);
NUnit.Framework.Assert.AreEqual(0, rc.Timeout);
NUnit.Framework.Assert.AreEqual(TagOpt.AUTO_FOLLOW, rc.TagOpt);
NUnit.Framework.Assert.AreEqual(1, allURIs.Count);
NUnit.Framework.Assert.AreEqual("http://www.spearce.org/egit.git", allURIs[0].ToString
());
NUnit.Framework.Assert.AreEqual(1, rc.FetchRefSpecs.Count);
spec = rc.FetchRefSpecs[0];
NUnit.Framework.Assert.IsTrue(spec.IsForceUpdate());
NUnit.Framework.Assert.IsTrue(spec.IsWildcard());
NUnit.Framework.Assert.AreEqual("refs/heads/*", spec.GetSource());
NUnit.Framework.Assert.AreEqual("refs/remotes/spearce/*", spec.GetDestination());
NUnit.Framework.Assert.AreEqual(0, rc.PushRefSpecs.Count);
}
示例3: 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;
}
示例4: 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()));
}
示例5: Open
/// <summary>Open a new transport instance to connect two repositories.</summary>
/// <remarks>
/// Open a new transport instance to connect two repositories.
/// <p>
/// This method assumes
/// <see cref="Operation.FETCH">Operation.FETCH</see>
/// .
/// </remarks>
/// <param name="local">existing local repository.</param>
/// <param name="cfg">
/// configuration describing how to connect to the remote
/// repository.
/// </param>
/// <returns>
/// the new transport instance. Never null. In case of multiple URIs
/// in remote configuration, only the first is chosen.
/// </returns>
/// <exception cref="System.NotSupportedException">the protocol specified is not supported.
/// </exception>
/// <exception cref="NGit.Errors.TransportException">the transport cannot open this URI.
/// </exception>
/// <exception cref="System.ArgumentException">
/// if provided remote configuration doesn't have any URI
/// associated.
/// </exception>
public static NGit.Transport.Transport Open(Repository local, RemoteConfig cfg)
{
return Open(local, cfg, Transport.Operation.FETCH);
}
示例6: GetURIs
private static IList<URIish> GetURIs(RemoteConfig cfg, Transport.Operation op)
{
switch (op)
{
case Transport.Operation.FETCH:
{
return cfg.URIs;
}
case Transport.Operation.PUSH:
{
IList<URIish> uris = cfg.PushURIs;
if (uris.IsEmpty())
{
uris = cfg.URIs;
}
return uris;
}
default:
{
throw new ArgumentException(op.ToString());
}
}
}
示例7: Push
public void Push (IProgressMonitor monitor, string remote, string remoteBranch)
{
RemoteConfig remoteConfig = new RemoteConfig (RootRepository.GetConfig (), remote);
Transport tp = Transport.Open (RootRepository, remoteConfig);
string remoteRef = "refs/heads/" + remoteBranch;
RemoteRefUpdate rr = new RemoteRefUpdate (RootRepository, RootRepository.GetBranch (), remoteRef, false, null, null);
List<RemoteRefUpdate> list = new List<RemoteRefUpdate> ();
list.Add (rr);
using (var gm = new GitMonitor (monitor))
tp.Push (gm, list);
switch (rr.GetStatus ()) {
case RemoteRefUpdate.Status.UP_TO_DATE: monitor.ReportSuccess (GettextCatalog.GetString ("Remote branch is up to date.")); break;
case RemoteRefUpdate.Status.REJECTED_NODELETE: monitor.ReportError (GettextCatalog.GetString ("The server is configured to deny deletion of the branch"), null); break;
case RemoteRefUpdate.Status.REJECTED_NONFASTFORWARD: monitor.ReportError (GettextCatalog.GetString ("The update is a non-fast-forward update. Merge the remote changes before pushing again."), null); break;
case RemoteRefUpdate.Status.OK:
monitor.ReportSuccess (GettextCatalog.GetString ("Push operation successfully completed."));
// Update the remote branch
ObjectId headId = rr.GetNewObjectId ();
RefUpdate updateRef = RootRepository.UpdateRef (Constants.R_REMOTES + remote + "/" + remoteBranch);
updateRef.SetNewObjectId(headId);
updateRef.Update();
break;
default:
string msg = rr.GetMessage ();
msg = !string.IsNullOrEmpty (msg) ? msg : GettextCatalog.GetString ("Push operation failed");
monitor.ReportError (msg, null);
break;
}
}
示例8: TestUploadPack
public virtual void TestUploadPack()
{
ReadConfig("[remote \"example\"]\n" + "url = [email protected]:egit.git\n" + "fetch = +refs/heads/*:refs/remotes/example/*\n"
+ "uploadpack = /path/to/git/git-upload-pack\n" + "receivepack = /path/to/git/git-receive-pack\n"
);
RemoteConfig rc = new RemoteConfig(config, "example");
IList<URIish> allURIs = rc.URIs;
RefSpec spec;
NUnit.Framework.Assert.AreEqual("example", rc.Name);
NUnit.Framework.Assert.IsNotNull(allURIs);
NUnit.Framework.Assert.IsNotNull(rc.FetchRefSpecs);
NUnit.Framework.Assert.IsNotNull(rc.PushRefSpecs);
NUnit.Framework.Assert.AreEqual(1, allURIs.Count);
NUnit.Framework.Assert.AreEqual("[email protected]:egit.git", allURIs[0].ToString(
));
NUnit.Framework.Assert.AreEqual(1, rc.FetchRefSpecs.Count);
spec = rc.FetchRefSpecs[0];
NUnit.Framework.Assert.IsTrue(spec.IsForceUpdate());
NUnit.Framework.Assert.IsTrue(spec.IsWildcard());
NUnit.Framework.Assert.AreEqual("refs/heads/*", spec.GetSource());
NUnit.Framework.Assert.AreEqual("refs/remotes/example/*", spec.GetDestination());
NUnit.Framework.Assert.AreEqual(0, rc.PushRefSpecs.Count);
NUnit.Framework.Assert.AreEqual("/path/to/git/git-upload-pack", rc.UploadPack);
NUnit.Framework.Assert.AreEqual("/path/to/git/git-receive-pack", rc.ReceivePack);
}
示例9: OpenAll
/// <summary>Open new transport instances to connect two repositories.</summary>
/// <remarks>
/// Open new transport instances to connect two repositories.
/// <p>
/// This method assumes
/// <see cref="Operation.FETCH">Operation.FETCH</see>
/// .
/// </remarks>
/// <param name="local">existing local repository.</param>
/// <param name="cfg">
/// configuration describing how to connect to the remote
/// repository.
/// </param>
/// <returns>
/// the list of new transport instances for every URI in remote
/// configuration.
/// </returns>
/// <exception cref="System.NotSupportedException">the protocol specified is not supported.
/// </exception>
/// <exception cref="NGit.Errors.TransportException">the transport cannot open this URI.
/// </exception>
public static IList<NGit.Transport.Transport> OpenAll(Repository local, RemoteConfig
cfg)
{
return OpenAll(local, cfg, Transport.Operation.FETCH);
}
示例10: ApplyConfig
/// <summary>Apply provided remote configuration on this transport.</summary>
/// <remarks>Apply provided remote configuration on this transport.</remarks>
/// <param name="cfg">configuration to apply on this transport.</param>
public virtual void ApplyConfig(RemoteConfig cfg)
{
SetOptionUploadPack(cfg.UploadPack);
SetOptionReceivePack(cfg.ReceivePack);
SetTagOpt(cfg.TagOpt);
fetch = cfg.FetchRefSpecs;
push = cfg.PushRefSpecs;
timeout = cfg.Timeout;
}
示例11: 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");
}
示例12: TestSimpleTimeout
public virtual void TestSimpleTimeout()
{
ReadConfig("[remote \"spearce\"]\n" + "url = http://www.spearce.org/egit.git\n" +
"fetch = +refs/heads/*:refs/remotes/spearce/*\n" + "timeout = 12\n");
RemoteConfig rc = new RemoteConfig(config, "spearce");
NUnit.Framework.Assert.AreEqual(12, rc.Timeout);
}
示例13: 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);
}
示例14: 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"
);
}
示例15: 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]);
}