private static void AssertRemoteHeadTipEquals(IRepository localRepo, string sha) { var remoteReferences = localRepo.Network.ListReferences(localRepo.Network.Remotes.Single()); DirectReference remoteHead = remoteReferences.Single(r => r.CanonicalName == "HEAD"); Assert.Equal(sha, remoteHead.TargetIdentifier); }
private void Spawn() { // spawns a cube object DirectReference cube = Instantiate(cubePrefab, transform.position, Quaternion.identity); // dependency injection happens here cube.Initialize(scoreManager); }
public void DirectReferenceCanConvertToJConstructorAndBack() { var reference = new DirectReference("aws_instance.my_instance"); var jc = reference.ToJConstructor(); var newReference = Reference.FromJConstructor(jc); newReference.ReferenceExpression.Should().Be(reference.ReferenceExpression); }
public void DirectReferenceCanBeEncodedAndDecoded() { var reference = new DirectReference("aws_instance.my_instance"); var jtoken = JObject.Parse(json); var property = (JProperty)jtoken.SelectToken("Property")?.Parent; property.Value = reference.ToJConstructor(); var token1 = JObject.Parse(jtoken.ToString(Formatting.None)); var con = (JConstructor)token1.SelectToken("Property"); var outReference = Reference.FromJConstructor(con); outReference.ReferenceExpression.Should().Be(reference.ReferenceExpression); }
public List <Post> ListPosts() { using (var repo = new Repository(_directory.FullName)) { var posts = new List <Post>(); // Get the most recent post from the content branch Branch branch = repo.Branches[CONTENT_BRANCH]; DirectReference commitRef = repo.Refs[branch.CanonicalName].ResolveToDirectReference(); for (Commit commit = repo.Lookup <Commit>(commitRef.Target.Id); commit.Parents.Any(); commit = commit.Parents.First()) { var post = JsonConvert.DeserializeObject <Post>(commit.Message); post.Id = commit.Sha; posts.Add(post); } return(posts); } }
private void RewriteReference(DirectReference oldRef, ObjectId newTarget, string backupNamePrefix, Queue <Action> rollbackActions) { string newRefName = oldRef.CanonicalName; if (oldRef.IsTag() && tagNameRewriter != null) { newRefName = Reference.TagPrefix + tagNameRewriter(oldRef.CanonicalName.Substring(Reference.TagPrefix.Length), false, oldRef.Target); } if (oldRef.Target.Id == newTarget && oldRef.CanonicalName == newRefName) { // The reference isn't rewritten return; } string backupName = backupNamePrefix + oldRef.CanonicalName.Substring("refs/".Length); if (repo.Refs.Resolve <Reference>(backupName) != null) { throw new InvalidOperationException( String.Format("Can't back up reference '{0}' - '{1}' already exists", oldRef.CanonicalName, backupName)); } repo.Refs.Add(backupName, oldRef.TargetIdentifier, false, "filter-branch: backup"); rollbackActions.Enqueue(() => repo.Refs.Remove(backupName)); Reference newRef = repo.Refs.UpdateTarget(oldRef, newTarget, "filter-branch: rewrite"); rollbackActions.Enqueue(() => repo.Refs.UpdateTarget(oldRef, oldRef.Target.Id, "filter-branch: abort")); if (newRef.CanonicalName == newRefName) { return; } repo.Refs.Move(newRef, newRefName); rollbackActions.Enqueue(() => repo.Refs.Move(newRef, oldRef.CanonicalName)); }
private void RewriteReference(DirectReference oldRef, ObjectId newTarget, string backupNamePrefix, Queue<Action> rollbackActions) { string newRefName = oldRef.CanonicalName; if (oldRef.IsTag() && tagNameRewriter != null) { newRefName = Reference.TagPrefix + tagNameRewriter(oldRef.CanonicalName.Substring(Reference.TagPrefix.Length), false, oldRef.Target); } if (oldRef.Target.Id == newTarget && oldRef.CanonicalName == newRefName) { // The reference isn't rewritten return; } string backupName = backupNamePrefix + oldRef.CanonicalName.Substring("refs/".Length); if (repo.Refs.Resolve<Reference>(backupName) != null) { throw new InvalidOperationException( String.Format("Can't back up reference '{0}' - '{1}' already exists", oldRef.CanonicalName, backupName)); } repo.Refs.Add(backupName, oldRef.TargetIdentifier, false, "filter-branch: backup"); rollbackActions.Enqueue(() => repo.Refs.Remove(backupName)); Reference newRef = repo.Refs.UpdateTarget(oldRef, newTarget, "filter-branch: rewrite"); rollbackActions.Enqueue(() => repo.Refs.UpdateTarget(oldRef, oldRef.Target.Id, "filter-branch: abort")); if (newRef.CanonicalName == newRefName) { return; } repo.Refs.Move(newRef, newRefName); rollbackActions.Enqueue(() => repo.Refs.Move(newRef, oldRef.CanonicalName)); }