public void test001_SplitLastColon() { string lhs = ":m:a:i:n:t"; string rhs = "refs/heads/maint"; RefSpec rs = new RefSpec(lhs + ":" + rhs); Assert.False(rs.Force); Assert.False(rs.Wildcard); Assert.AreEqual(lhs, rs.Source); Assert.AreEqual(rhs, rs.Destination); Assert.AreEqual(lhs + ":" + rhs, rs.ToString()); Assert.AreEqual(rs, new RefSpec(rs.ToString())); }
public void test000_MasterMaster() { string sn = "refs/heads/master"; RefSpec rs = new RefSpec(sn + ":" + sn); Assert.False(rs.Force); Assert.False(rs.Wildcard); Assert.AreEqual(sn, rs.Source); Assert.AreEqual(sn, rs.Destination); Assert.AreEqual(sn + ":" + sn, rs.ToString()); Assert.AreEqual(rs, new RefSpec(rs.ToString())); Ref r = new Ref(Ref.Storage.Loose, sn, null); Assert.True(rs.MatchSource(r)); Assert.True(rs.MatchDestination(r)); Assert.AreSame(rs, rs.ExpandFromSource(r)); r = new Ref(Ref.Storage.Loose, sn + "-and-more", null); Assert.False(rs.MatchSource(r)); Assert.False(rs.MatchDestination(r)); }
public void test012_ExpandFromDestination_Wildcard() { string src = "refs/heads/master"; string dst = "refs/remotes/origin/master"; RefSpec a = new RefSpec("refs/heads/*:refs/remotes/origin/*"); RefSpec r = a.ExpandFromDestination(dst); Assert.AreNotSame(a, r); Assert.False(r.Wildcard); Assert.AreEqual(src, r.Source); Assert.AreEqual(dst, r.Destination); }
public void test011_SetSourceDestination() { RefSpec a = new RefSpec(); RefSpec b; b = a.SetSourceDestination("refs/heads/*", "refs/remotes/origin/*"); Assert.AreNotSame(a, b); Assert.AreEqual("HEAD", a.ToString()); Assert.AreEqual("refs/heads/*:refs/remotes/origin/*", b.ToString()); }
public void test010_SetDestination_SourceNull() { RefSpec a = new RefSpec(); RefSpec b; b = a.SetDestination("refs/heads/master"); b = b.SetSource(null); Assert.AreNotSame(a, b); Assert.AreEqual("HEAD", a.ToString()); Assert.AreEqual(":refs/heads/master", b.ToString()); }
private RefSpec(RefSpec p) { Force = p.Force; Wildcard = p.Wildcard; Source = p.Source; Destination = p.Destination; }
private void expandWildcard(RefSpec spec, HashSet<Ref> matched) { foreach (Ref src in _connection.Refs) { if (spec.MatchSource(src) && matched.Add(src)) want(src, spec.ExpandFromSource((src))); } }
private void deleteTrackingRef(FetchResult result, Repository db, RevWalk.RevWalk walk, RefSpec spec, Ref localRef) { string name = localRef.Name; try { TrackingRefUpdate u = new TrackingRefUpdate(db, name, spec.Source, true, ObjectId.ZeroId, "deleted"); result.Add(u); if (_transport.DryRun) { return; } u.Delete(walk); switch (u.Result) { case RefUpdate.RefUpdateResult.New: case RefUpdate.RefUpdateResult.NoChange: case RefUpdate.RefUpdateResult.FastForward: case RefUpdate.RefUpdateResult.Forced: break; default: throw new TransportException(_transport.Uri, "Cannot delete stale tracking ref " + name + ": " + u.Result.ToString()); } } catch (System.IO.IOException e) { throw new TransportException(_transport.Uri, "Cannot delete stale tracking ref " + name, e); } }
public void test007_CreateEmpty() { RefSpec rs = new RefSpec(); Assert.False(rs.Force); Assert.False(rs.Wildcard); Assert.AreEqual("HEAD", rs.Source); Assert.Null(rs.Destination); Assert.AreEqual("HEAD", rs.ToString()); }
public void test006_ForceRemotesOrigin() { string srcn = "refs/heads/*"; string dstn = "refs/remotes/origin/*"; RefSpec rs = new RefSpec("+" + srcn + ":" + dstn); Assert.True(rs.Force); Assert.True(rs.Wildcard); Assert.AreEqual(srcn, rs.Source); Assert.AreEqual(dstn, rs.Destination); Assert.AreEqual("+" + srcn + ":" + dstn, rs.ToString()); Assert.AreEqual(rs, new RefSpec(rs.ToString())); Ref r; RefSpec expanded; r = new Ref(Ref.Storage.Loose, "refs/heads/master", null); Assert.True(rs.MatchSource(r)); Assert.False(rs.MatchDestination(r)); expanded = rs.ExpandFromSource(r); Assert.AreNotSame(rs, expanded); Assert.True(expanded.Force); Assert.False(expanded.Wildcard); Assert.AreEqual(r.Name, expanded.Source); Assert.AreEqual("refs/remotes/origin/master", expanded.Destination); r = new Ref(Ref.Storage.Loose, "refs/remotes/origin/next", null); Assert.False(rs.MatchSource(r)); Assert.True(rs.MatchDestination(r)); r = new Ref(Ref.Storage.Loose, "refs/tags/v1.0", null); Assert.False(rs.MatchSource(r)); Assert.False(rs.MatchDestination(r)); }
public bool RemovePushRefSpec(RefSpec s) { return Push.Remove(s); }
public bool AddPushRefSpec(RefSpec s) { if (Push.Contains(s)) return false; Push.Add(s); return true; }
public bool RemoveFetchRefSpec(RefSpec s) { return Fetch.Remove(s); }
public bool AddFetchRefSpec(RefSpec s) { if (Fetch.Contains(s)) return false; Fetch.Add(s); return true; }
public RefSpec SetDestination(string destination) { RefSpec r = new RefSpec(this); r.Destination = destination; if (IsWildcard(r.Destination) && r.Source == null) throw new ArgumentException("Source is not a wildcard."); if (IsWildcard(r.Source) != IsWildcard(r.Destination)) throw new ArgumentException("Source/Destination must match."); return r; }
public void test008_SetForceUpdate() { string s = "refs/heads/*:refs/remotes/origin/*"; RefSpec a = new RefSpec(s); Assert.False(a.Force); RefSpec b = a.SetForce(true); Assert.AreNotSame(a, b); Assert.False(a.Force); Assert.True(b.Force); Assert.AreEqual(s, a.ToString()); Assert.AreEqual("+" + s, b.ToString()); }
private TrackingRefUpdate createUpdate(RefSpec spec, ObjectId newId) { return new TrackingRefUpdate(_transport.Local, spec, newId, "fetch"); }
public void test009_SetSource() { RefSpec a = new RefSpec(); RefSpec b = a.SetSource("refs/heads/master"); Assert.AreNotSame(a, b); Assert.AreEqual("HEAD", a.ToString()); Assert.AreEqual("refs/heads/master", b.ToString()); }
private void expandSingle(RefSpec spec, HashSet<Ref> matched) { Ref src = _connection.Refs.Find(x => x.Name == spec.Source); if (src == null) { throw new TransportException("Remote does not have " + spec.Source + " available for fetch."); } if (matched.Add(src)) { want(src, spec); } }
public void test010_SetDestination() { RefSpec a = new RefSpec(); RefSpec b = a.SetDestination("refs/heads/master"); Assert.AreNotSame(a, b); Assert.AreEqual("HEAD", a.ToString()); Assert.AreEqual("HEAD:refs/heads/master", b.ToString()); }
private void want(Ref src, RefSpec spec) { ObjectId newId = src.ObjectId; if (spec.Destination != null) { try { TrackingRefUpdate tru = createUpdate(spec, newId); if (newId.Equals(tru.OldObjectId)) { return; } _localUpdates.Add(tru); } catch (System.IO.IOException err) { // Bad symbolic ref? That is the most likely cause. throw new TransportException("Cannot resolve" + " local tracking ref " + spec.Destination + " for updating.", err); } } _askFor.Add(newId, src); FetchHeadRecord fhr = new FetchHeadRecord(newId, spec.Destination != null, src.Name, _transport.Uri); _fetchHeadUpdates.Add(fhr); }
private FetchResult fetchFromBundle(Repository newRepo, byte[] bundle) { var uri = new URIish("in-memory://"); var @in = new MemoryStream(bundle); var rs = new RefSpec("refs/heads/*:refs/heads/*"); var refs = new List<RefSpec>{rs}; return new TransportBundleStream(newRepo, uri, @in).fetch(NullProgressMonitor.Instance, refs); }