Example #1
0
        /// <exception cref="NGit.Errors.TransportException"></exception>
        private ICollection <Ref> ExpandAutoFollowTags()
        {
            ICollection <Ref>         additionalTags = new AList <Ref>();
            IDictionary <string, Ref> haveRefs       = transport.local.GetAllRefs();

            foreach (Ref r in conn.GetRefs())
            {
                if (!IsTag(r))
                {
                    continue;
                }
                Ref      local = haveRefs.Get(r.GetName());
                ObjectId obj   = r.GetObjectId();
                if (r.GetPeeledObjectId() == null)
                {
                    if (local != null && obj.Equals(local.GetObjectId()))
                    {
                        continue;
                    }
                    if (askFor.ContainsKey(obj) || transport.local.HasObject(obj))
                    {
                        WantTag(r);
                    }
                    else
                    {
                        additionalTags.AddItem(r);
                    }
                    continue;
                }
                if (local != null)
                {
                    if (!obj.Equals(local.GetObjectId()))
                    {
                        WantTag(r);
                    }
                }
                else
                {
                    if (askFor.ContainsKey(r.GetPeeledObjectId()) || transport.local.HasObject(r.GetPeeledObjectId
                                                                                                   ()))
                    {
                        WantTag(r);
                    }
                    else
                    {
                        additionalTags.AddItem(r);
                    }
                }
            }
            return(additionalTags);
        }
        public void deleteFolder(string currFolder)
        {
            MapFolderDB folderManeger = new MapFolderDB(new Settings());
            ObjectId    currFolderID  = new ObjectId(currFolder);
            MapFolder   currentFolder = folderManeger.GetMapFolderById(currFolderID);

            try
            {
                foreach (ObjectId idOfSubFolder in currentFolder.idOfSubFolders)
                {
                    deleteFolder(idOfSubFolder.ToString());
                }
            }
            catch
            {
            }
            ObjectId  prevFolderID = currentFolder.ParentDierctory;
            MapFolder prevFolder   = folderManeger.GetMapFolderById(prevFolderID);

            foreach (ObjectId objID in prevFolder.idOfSubFolders)
            {
                if (currFolderID.Equals(objID))
                {
                    currFolderID = objID;
                }
            }
            prevFolder.idOfSubFolders.Remove(currFolderID);
            folderManeger.UpdateMapFolder(prevFolder);
            folderManeger.RemoveMapFolderById(currFolderID);
            ViewBag.go2 = prevFolderID.ToString();
        }
Example #3
0
        public void testRenameRefNameColission1avoided()
        {
            // setup
            ObjectId rb = db.Resolve("refs/heads/b");

            writeSymref(Constants.HEAD, "refs/heads/a");
            RefUpdate updateRef = db.UpdateRef("refs/heads/a");

            updateRef.NewObjectId = rb;
            updateRef.setRefLogMessage("Setup", false);
            Assert.AreEqual(RefUpdate.RefUpdateResult.FAST_FORWARD, updateRef.update());
            ObjectId oldHead = db.Resolve(Constants.HEAD);

            Assert.IsTrue(rb.Equals(oldHead)); // assumption for this test
            writeReflog(db, rb, rb, "Just a message", "refs/heads/a");
            Assert.IsTrue(new FileInfo(Path.Combine(db.Directory.FullName, "logs/refs/heads/a")).Exists, "internal check, we have a log");

            // Now this is our test
            RefRename renameRef = db.RenameRef("refs/heads/a", "refs/heads/a/b");

            RefUpdate.RefUpdateResult result = renameRef.rename();
            Assert.AreEqual(RefUpdate.RefUpdateResult.RENAMED, result);
            Assert.IsNull(db.Resolve("refs/heads/a"));
            Assert.AreEqual(rb, db.Resolve("refs/heads/a/b"));
            Assert.AreEqual(3, db.ReflogReader("a/b").getReverseEntries().Count);
            Assert.AreEqual("Branch: renamed a to a/b", db.ReflogReader("a/b")
                            .getReverseEntries()[0].getComment());
            Assert.AreEqual("Just a message", db.ReflogReader("a/b")
                            .getReverseEntries()[1].getComment());
            Assert.AreEqual("Setup", db.ReflogReader("a/b").getReverseEntries()
                            [2].getComment());
            // same thing was logged to HEAD
            Assert.AreEqual("Branch: renamed a to a/b", db.ReflogReader("HEAD")
                            .getReverseEntries()[0].getComment());
        }
Example #4
0
        public async Task UpdateAsync(ObjectId issueId, ObjectId requirementId, IssueRequirement requirement)
        {
            if (requirementId.Equals(requirement.Id) is false)
            {
                throw new HttpStatusException(400, "Die ID des Pfades passt nicht zu der ID der Ressource.");
            }

            var issue = await _issueRepo.GetAsync(issueId);

            if (issue is null)
            {
                throw new HttpStatusException(400, "Das angefragte Issue Existiert nicht");
            }

            if (string.IsNullOrWhiteSpace(requirement.Requirement))
            {
                throw new HttpStatusException(400, "Bitte geben Sie eine valide Anforderung an");
            }

            var req = issue.IssueDetail.Requirements.First(it => it.Id == requirement.Id);

            await SetRequirementFieldsAsync(issue, req, requirement);

            await _issueRepo.UpdateAsync(issue);
        }
Example #5
0
        public bool Equals(Pickup other)
        {
            if (other == null)
            {
                return(false);
            }

            return(Index.Equals(other.Index) &&
                   Unknown04h.Equals(other.Unknown04h) &&
                   Unknown08h.Equals(other.Unknown08h) &&
                   Amount.Equals(other.Amount) &&
                   Unknown10h.Equals(other.Unknown10h) &&
                   Unknown14h.Equals(other.Unknown14h) &&
                   Blip.Equals(other.Blip) &&
                   Timer.Equals(other.Timer) &&
                   Position.Equals(other.Position) &&
                   Unknown2Ch.Equals(other.Unknown2Ch) &&
                   Unknown30h.Equals(other.Unknown30h) &&
                   Rotation.Equals(other.Rotation) &&
                   Unknown40h.Equals(other.Unknown40h) &&
                   ObjectId.Equals(other.ObjectId) &&
                   RefNum.Equals(other.RefNum) &&
                   PickupType.Equals(other.PickupType) &&
                   Flags.Equals(other.Flags) &&
                   Flags2.Equals(other.Flags2) &&
                   Unknown4Bh.Equals(other.Unknown4Bh) &&
                   Unknown4Ch.Equals(other.Unknown4Ch) &&
                   Unknown50h.Equals(other.Unknown50h));
        }
Example #6
0
        public void testRenameCurrentBranch()
        {
            ObjectId rb = db.Resolve("refs/heads/b");

            writeSymref(Constants.HEAD, "refs/heads/b");
            ObjectId oldHead = db.Resolve(Constants.HEAD);

            Assert.IsTrue(rb.Equals(oldHead), "internal test condition, b == HEAD");
            writeReflog(db, rb, rb, "Just a message", "refs/heads/b");
            Assert.IsTrue(new FileInfo(Path.Combine(db.Directory.FullName, "logs/refs/heads/b")).Exists, "log on old branch");
            RefRename renameRef = db.RenameRef("refs/heads/b",
                                               "refs/heads/new/name");

            RefUpdate.RefUpdateResult result = renameRef.rename();
            Assert.AreEqual(RefUpdate.RefUpdateResult.RENAMED, result);
            Assert.AreEqual(rb, db.Resolve("refs/heads/new/name"));
            Assert.IsNull(db.Resolve("refs/heads/b"));
            Assert.AreEqual("Branch: renamed b to new/name", db.ReflogReader(
                                "new/name").getLastEntry().getComment());
            Assert.IsFalse(new FileInfo(Path.Combine(db.Directory.FullName, "logs/refs/heads/b")).Exists);
            Assert.AreEqual(rb, db.Resolve(Constants.HEAD));
            Assert.AreEqual(2, db.ReflogReader("new/name").getReverseEntries().Count);
            Assert.AreEqual("Branch: renamed b to new/name", db.ReflogReader("new/name").getReverseEntries()[0].getComment());
            Assert.AreEqual("Just a message", db.ReflogReader("new/name").getReverseEntries()[1].getComment());
        }
Example #7
0
        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);
        }
Example #8
0
        public virtual void TestPathsReset()
        {
            SetupRepository();
            DirCacheEntry preReset = DirCache.Read(db.GetIndexFile(), db.FileSystem).GetEntry
                                         (indexFile.GetName());

            NUnit.Framework.Assert.IsNotNull(preReset);
            git.Add().AddFilepattern(untrackedFile.GetName()).Call();
            // 'a.txt' has already been modified in setupRepository
            // 'notAddedToIndex.txt' has been added to repository
            git.Reset().AddPath(indexFile.GetName()).AddPath(untrackedFile.GetName()).Call();
            DirCacheEntry postReset = DirCache.Read(db.GetIndexFile(), db.FileSystem).GetEntry
                                          (indexFile.GetName());

            NUnit.Framework.Assert.IsNotNull(postReset);
            NUnit.Framework.Assert.AreNotSame(preReset.GetObjectId(), postReset.GetObjectId()
                                              );
            NUnit.Framework.Assert.AreEqual(prestage.GetObjectId(), postReset.GetObjectId());
            // check that HEAD hasn't moved
            ObjectId head = db.Resolve(Constants.HEAD);

            NUnit.Framework.Assert.IsTrue(head.Equals(secondCommit));
            // check if files still exist
            NUnit.Framework.Assert.IsTrue(untrackedFile.Exists());
            NUnit.Framework.Assert.IsTrue(indexFile.Exists());
            NUnit.Framework.Assert.IsTrue(InHead(indexFile.GetName()));
            NUnit.Framework.Assert.IsTrue(InIndex(indexFile.GetName()));
            NUnit.Framework.Assert.IsFalse(InIndex(untrackedFile.GetName()));
        }
Example #9
0
 public async Task <ActionResult> Register(RegisterViewModel model)
 {
     if (ModelState.IsValid)
     {
         if (UserContext.IsContains(model.email))
         {
             return(RedirectToAction("Register", "Authorization"));
         }
         User user = new User();
         user.firstName = model.fristname;
         user.lastName  = model.lastname;
         user.username  = model.email.Substring(0, model.email.IndexOf("@"));
         user.email     = model.email;
         user.password  = model.Password;
         ObjectId userId = UserContext.Save(user);
         if (userId.Equals(ObjectId.Empty))
         {
             return(RedirectToAction("Register", "Authorization"));
         }
         //Set Login
         FormsAuthentication.SetAuthCookie(user.username, false);
         UserProfileView userProfileModel = new UserProfileView();
         userProfileModel.username = user.username;
         userProfileModel.address  = user.password;
         userProfileModel.Id       = userId;
         UserHelpers.SetCurrentUser(Session, userProfileModel);
         return(RedirectToAction("Index", "Home"));
     }
     // If we got this far, something failed, redisplay form
     return(View(model));
 }
Example #10
0
        public virtual void TestRenameBranchHasPreviousLog()
        {
            ObjectId rb      = db.Resolve("refs/heads/b");
            ObjectId oldHead = db.Resolve(Constants.HEAD);

            NUnit.Framework.Assert.IsFalse(rb.Equals(oldHead), "precondition for this test, branch b != HEAD"
                                           );
            WriteReflog(db, rb, "Just a message", "refs/heads/b");
            NUnit.Framework.Assert.IsTrue(new FilePath(db.Directory, "logs/refs/heads/b").Exists
                                              (), "log on old branch");
            RefRename renameRef = db.RenameRef("refs/heads/b", "refs/heads/new/name");

            RefUpdate.Result result = renameRef.Rename();
            NUnit.Framework.Assert.AreEqual(RefUpdate.Result.RENAMED, result);
            NUnit.Framework.Assert.AreEqual(rb, db.Resolve("refs/heads/new/name"));
            NUnit.Framework.Assert.IsNull(db.Resolve("refs/heads/b"));
            NUnit.Framework.Assert.AreEqual(2, db.GetReflogReader("new/name").GetReverseEntries
                                                ().Count);
            NUnit.Framework.Assert.AreEqual("Branch: renamed b to new/name", db.GetReflogReader
                                                ("new/name").GetLastEntry().GetComment());
            NUnit.Framework.Assert.AreEqual("Just a message", db.GetReflogReader("new/name").
                                            GetReverseEntries()[1].GetComment());
            NUnit.Framework.Assert.IsFalse(new FilePath(db.Directory, "logs/refs/heads/b").Exists
                                               ());
            NUnit.Framework.Assert.AreEqual(oldHead, db.Resolve(Constants.HEAD));
        }
Example #11
0
        /// <exception cref="NGit.Errors.TransportException"></exception>
        private void Want(Ref src, RefSpec spec)
        {
            ObjectId newId = src.GetObjectId();

            if (spec.GetDestination() != null)
            {
                try
                {
                    TrackingRefUpdate tru = CreateUpdate(spec, newId);
                    if (newId.Equals(tru.GetOldObjectId()))
                    {
                        return;
                    }
                    localUpdates.AddItem(tru);
                }
                catch (IOException err)
                {
                    // Bad symbolic ref? That is the most likely cause.
                    //
                    throw new TransportException(MessageFormat.Format(JGitText.Get().cannotResolveLocalTrackingRefForUpdating
                                                                      , spec.GetDestination()), err);
                }
            }
            askFor.Put(newId, src);
            FetchHeadRecord fhr = new FetchHeadRecord();

            fhr.newValue    = newId;
            fhr.notForMerge = spec.GetDestination() != null;
            fhr.sourceName  = src.GetName();
            fhr.sourceURI   = transport.GetURI();
            fetchHeadUpdates.AddItem(fhr);
        }
Example #12
0
        /// <summary>
        /// Updates the instance.
        /// </summary>
        /// <param name="objectUpdate">The object update.</param>
        /// <returns>IPureObject.</returns>
        /// <autogeneratedoc />
        public virtual IPureObject UpdateInstance(IPureObject objectUpdate)
        {
            if (objectUpdate == null)
            {
                throw new ArgumentNullException(nameof(objectUpdate));
            }

            if (ObjectId.Equals(objectUpdate.ObjectId))
            {
                if (objectUpdate.ObjectVersion > ObjectVersion)
                {
                    Logger?.LogTrace("IPureObject:UpdateInstance: ");
                    ObjectVersion = objectUpdate.ObjectVersion;
                }

                IncrementObjectVersion();
                ModifiedTimestamp = DateTimeOffset.Now;
            }
            else
            {
                Logger?.LogDebug("UpdateInstance called when {CurObjectId} != {UpdateObjectId}", ObjectId,
                                 objectUpdate.ObjectId);
            }

            return(this);
        }
Example #13
0
        /// <summary>
        /// Creates or replaces the provided conversation item, based on the id.
        /// </summary>
        /// <param name="issueId">The issue on which the operation will be executed at.</param>
        /// <param name="conversationItemId">The id of the conversation.</param>
        /// <param name="conversationItem">The conversation that will be created or replaced if already existing.</param>
        public async Task CreateOrReplaceConversationItemAsync(string issueId, string conversationItemId, IssueConversationDTO conversationItem)
        {
            ObjectId conversationItemOid = Validators.ValidateObjectId(conversationItemId, "Provided conversation id is no valid ObjectId.");

            var issue = await _issueRepository.GetIssueByIdAsync(issueId);

            await AssertUserCanWriteConversation(issue);

            if (conversationItemOid.Equals(conversationItem.Id) is false)
            {
                throw new HttpStatusException(StatusCodes.Status400BadRequest, "Id missmatch.");
            }

            var issueConversationModel = new IssueConversation()
            {
                Id            = conversationItem.Id,
                CreatorUserId = Validators.ValidateObjectId(conversationItem.Creator?.Id.ToString(), "The conversation item is missing a valid userId."),
                Data          = conversationItem.Data,
                // Conversation from the outside  is always a message and
                // can therefore not contain requirements
                Requirements = null,
                Type         = IssueConversation.MessageType,
            };

            await _issueRepository.CreateOrUpdateConversationItemAsync(issueId, issueConversationModel);
        }
        public void InsertChineseTest()
        {
            BsonDocument insertor = new BsonDocument();

            insertor.Add("姓名", "林海涛");
            insertor.Add("年龄", 24);
            insertor.Add("id", 2001);

            // an embedded bson object
            BsonDocument phone = new BsonDocument
            {
                { "0", "10086" },
                { "1", "10000" }
            };

            insertor.Add("电话", phone);

            ObjectId id = (ObjectId)coll.Insert(insertor);

            BsonDocument matcher = new BsonDocument();
            DBQuery      query   = new DBQuery();

            matcher.Add("姓名", "林海涛");
            query.Matcher = matcher;
            DBCursor cursor = coll.Query(query);

            Assert.IsNotNull(cursor);
            BsonDocument rtn = cursor.Next();

            Assert.IsNotNull(rtn);
            Assert.IsTrue(id.Equals(rtn["_id"].AsObjectId));
        }
Example #15
0
 public IEnumerable <ProductType> GetFromVariety(ObjectId varietyId)
 {
     if (varietyId == null)
     {
         throw new ArgumentException("VatietyID is null or empty");
     }
     return(_productTypes.Find(ProductType => ObjectId.Equals(ProductType.VarietyID, varietyId)).ToList());
 }
Example #16
0
 public bool Equals(Character other)
 {
     if (other is null)
     {
         return(false);
     }
     return(ObjectId.Equals(other.ObjectId));
 }
Example #17
0
 public void Remove(ProductType removableProductType)
 {
     if (removableProductType == null)
     {
         throw new ArgumentException("removableProductType is null or empty");
     }
     _productTypes.DeleteOne(ProductVariety => ObjectId.Equals(removableProductType.Id, ProductVariety.Id));
 }
Example #18
0
 /// <summary>
 /// Check if the current entry of both iterators has the same id.
 /// <para />
 /// This method is faster than <see cref="getEntryObjectId()"/>as it does not
 /// require copying the bytes out of the buffers. A direct <see cref="idBuffer"/>
 /// compare operation is performed.
 /// </summary>
 /// <param name="otherIterator">the other iterator to test against.</param>
 /// <returns>
 /// true if both iterators have the same object id; false otherwise.
 /// </returns>
 public virtual bool idEqual(AbstractTreeIterator otherIterator)
 {
     if (otherIterator == null)
     {
         throw new ArgumentNullException("otherIterator");
     }
     return(ObjectId.Equals(idBuffer(), idOffset(), otherIterator.idBuffer(), otherIterator.idOffset()));
 }
 public ToDoList GetBy(ObjectId id)
 {
     if (id.Equals(null))
     {
         throw new System.Exception("id isnt valid");
     }
     return(_userCollection.Find(c => c.Id == id).First());
 }
Example #20
0
 /// <exception cref="System.IO.IOException"></exception>
 private static RawText GetRawText(ObjectId id, Repository db)
 {
     if (id.Equals(ObjectId.ZeroId))
     {
         return(new RawText(new byte[] {  }));
     }
     return(new RawText(db.Open(id, Constants.OBJ_BLOB).GetCachedBytes()));
 }
 public void Delete(ObjectId id)
 {
     if (id.Equals(null))
     {
         throw new System.Exception("id isnt valid");
     }
     _userCollection.DeleteOne(c => c.Id == id);
 }
Example #22
0
 public void Remove(ObjectId id)
 {
     if (id == null)
     {
         throw new ArgumentException("id is null or empty");
     }
     _products.DeleteOne(Product => ObjectId.Equals(id, Product.Id));
 }
Example #23
0
 public Product Get(ObjectId id)
 {
     if (id == null)
     {
         throw new ArgumentException("id is null or empty");
     }
     return(_products.Find <Product>(Product => ObjectId.Equals(id, Product.Id)).FirstOrDefault());
 }
Example #24
0
        public void test003_equals()
        {
            string   x = "def4c620bc3713bb1bb26b808ec9312548e73946";
            ObjectId a = ObjectId.FromString(x);
            ObjectId b = ObjectId.FromString(x);

            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());
            Assert.IsTrue(a.Equals(b), "a and b are same");
        }
Example #25
0
        /// <summary>Load the configuration as a Git text style configuration file.</summary>
        /// <remarks>
        /// Load the configuration as a Git text style configuration file.
        /// <p>
        /// If the file does not exist, this configuration is cleared, and thus
        /// behaves the same as though the file exists, but is empty.
        /// </remarks>
        /// <exception cref="System.IO.IOException">the file could not be read (but does exist).
        ///     </exception>
        /// <exception cref="NGit.Errors.ConfigInvalidException">the file is not a properly formatted configuration file.
        ///     </exception>
        public override void Load()
        {
            FileSnapshot oldSnapshot = snapshot;
            FileSnapshot newSnapshot = FileSnapshot.Save(GetFile());

            try
            {
                byte[]   @in     = IOUtil.ReadFully(GetFile());
                ObjectId newHash = Hash(@in);
                if (hash.Equals(newHash))
                {
                    if (oldSnapshot.Equals(newSnapshot))
                    {
                        oldSnapshot.SetClean(newSnapshot);
                    }
                    else
                    {
                        snapshot = newSnapshot;
                    }
                }
                else
                {
                    string decoded;
                    if (@in.Length >= 3 && @in[0] == unchecked ((byte)unchecked ((int)(0xEF))) && @in[1
                        ] == unchecked ((byte)unchecked ((int)(0xBB))) && @in[2] == unchecked ((byte)unchecked (
                                                                                                   (int)(0xBF))))
                    {
                        decoded = RawParseUtils.Decode(RawParseUtils.UTF8_CHARSET, @in, 3, @in.Length);
                        utf8Bom = true;
                    }
                    else
                    {
                        decoded = RawParseUtils.Decode(@in);
                    }
                    FromText(decoded);
                    snapshot = newSnapshot;
                    hash     = newHash;
                }
            }
            catch (FileNotFoundException)
            {
                Clear();
                snapshot = newSnapshot;
            }
            catch (IOException e)
            {
                IOException e2 = new IOException(MessageFormat.Format(JGitText.Get().cannotReadFile
                                                                      , GetFile()));
                Sharpen.Extensions.InitCause(e2, e);
                throw e2;
            }
            catch (ConfigInvalidException e)
            {
                throw new ConfigInvalidException(MessageFormat.Format(JGitText.Get().cannotReadFile
                                                                      , GetFile()), e);
            }
        }
Example #26
0
 public void SimilarObjectIdsAreEqual()
 {
     var a = new ObjectId("ce08fe4884650f067bd5703b6a59a8b3b3c99a09");
     var b = new ObjectId("ce08fe4884650f067bd5703b6a59a8b3b3c99a09");
     (a.Equals(b)).ShouldBeTrue();
     (b.Equals(a)).ShouldBeTrue();
     (a == b).ShouldBeTrue();
     (a != b).ShouldBeFalse();
 }
Example #27
0
        public void Equality()
        {
            ObjectId id = new ObjectId();

            // Negative cases:
            ObjectId id2 = new ObjectId();

            Assert.IsFalse(id == id2);
            Assert.IsTrue(id != id2);
            Assert.IsFalse(id.Equals(id2));

            // Positive cases:
            ObjectId idDeserialized = new ObjectId(id.ToString());

            Assert.IsTrue(id.Equals(idDeserialized));
            Assert.IsFalse(id == idDeserialized);
            Assert.IsTrue(id != idDeserialized);
        }
Example #28
0
 public bool Equals(MarkSb other)
 {
     return(_markSb.Equals(other._markSb) &&
            _colorAreas.SequenceEqual(other._colorAreas) &&
            _idBtr.Equals(other._idBtr) &&
            _paints.SequenceEqual(other._paints) &&
            _tiles.SequenceEqual(other._tiles) &&
            _marksAR.SequenceEqual(other._marksAR));
 }
Example #29
0
 /// <summary>Construct remote ref update request by providing an update specification.
 ///     </summary>
 /// <remarks>
 /// Construct remote ref update request by providing an update specification.
 /// Object is created with default
 /// <see cref="Status.NOT_ATTEMPTED">Status.NOT_ATTEMPTED</see>
 /// status and no
 /// message.
 /// </remarks>
 /// <param name="localDb">local repository to push from.</param>
 /// <param name="srcRef">
 /// source revision to label srcId with. If null srcId.name() will
 /// be used instead.
 /// </param>
 /// <param name="srcId">
 /// The new object that the caller wants remote ref to be after
 /// update. Use null or
 /// <see cref="NGit.ObjectId.ZeroId()">NGit.ObjectId.ZeroId()</see>
 /// for delete
 /// request.
 /// </param>
 /// <param name="remoteName">
 /// full name of a remote ref to update, e.g. "refs/heads/master"
 /// (no wildcard, no short name).
 /// </param>
 /// <param name="forceUpdate">
 /// true when caller want remote ref to be updated regardless
 /// whether it is fast-forward update (old object is ancestor of
 /// new object).
 /// </param>
 /// <param name="localName">
 /// optional full name of a local stored tracking branch, to
 /// update after push, e.g. "refs/remotes/zawir/dirty" (no
 /// wildcard, no short name); null if no local tracking branch
 /// should be updated.
 /// </param>
 /// <param name="expectedOldObjectId">
 /// optional object id that caller is expecting, requiring to be
 /// advertised by remote side before update; update will take
 /// place ONLY if remote side advertise exactly this expected id;
 /// null if caller doesn't care what object id remote side
 /// advertise. Use
 /// <see cref="NGit.ObjectId.ZeroId()">NGit.ObjectId.ZeroId()</see>
 /// when expecting no
 /// remote ref with this name.
 /// </param>
 /// <exception cref="System.IO.IOException">
 /// when I/O error occurred during creating
 /// <see cref="TrackingRefUpdate">TrackingRefUpdate</see>
 /// for local tracking branch or srcRef
 /// can't be resolved to any object.
 /// </exception>
 /// <exception cref="System.ArgumentException">if some required parameter was null</exception>
 public RemoteRefUpdate(Repository localDb, string srcRef, ObjectId srcId, string
                        remoteName, bool forceUpdate, string localName, ObjectId expectedOldObjectId)
 {
     if (remoteName == null)
     {
         throw new ArgumentException(JGitText.Get().remoteNameCantBeNull);
     }
     if (srcId == null && srcRef != null)
     {
         throw new IOException(MessageFormat.Format(JGitText.Get().sourceRefDoesntResolveToAnyObject
                                                    , srcRef));
     }
     if (srcRef != null)
     {
         this.srcRef = srcRef;
     }
     else
     {
         if (srcId != null && !srcId.Equals(ObjectId.ZeroId))
         {
             this.srcRef = srcId.Name;
         }
         else
         {
             this.srcRef = null;
         }
     }
     if (srcId != null)
     {
         this.newObjectId = srcId;
     }
     else
     {
         this.newObjectId = ObjectId.ZeroId;
     }
     this.remoteName  = remoteName;
     this.forceUpdate = forceUpdate;
     if (localName != null && localDb != null)
     {
         localUpdate = localDb.UpdateRef(localName);
         localUpdate.SetForceUpdate(true);
         localUpdate.SetRefLogMessage("push", true);
         localUpdate.SetNewObjectId(newObjectId);
         trackingRefUpdate = new TrackingRefUpdate(true, remoteName, localName, localUpdate
                                                   .GetOldObjectId() != null ? localUpdate.GetOldObjectId() : ObjectId.ZeroId, newObjectId
                                                   );
     }
     else
     {
         trackingRefUpdate = null;
     }
     this.localDb             = localDb;
     this.expectedOldObjectId = expectedOldObjectId;
     this.status = RemoteRefUpdate.Status.NOT_ATTEMPTED;
 }
Example #30
0
        public void SimilarObjectIdsAreEqual()
        {
            var a = new ObjectId(validSha1);
            var b = new ObjectId(validSha1);

            (a.Equals(b)).ShouldBeTrue();
            (b.Equals(a)).ShouldBeTrue();

            (a == b).ShouldBeTrue();
            (a != b).ShouldBeFalse();
        }
Example #31
0
        public void DifferentObjectIdsAreEqual()
        {
            var a = new ObjectId(validSha1);
            var b = new ObjectId(validSha2);

            (a.Equals(b)).ShouldBeFalse();
            (b.Equals(a)).ShouldBeFalse();

            (a == b).ShouldBeFalse();
            (a != b).ShouldBeTrue();
        }
Example #32
0
        public void SimilarObjectIdsAreEqual()
        {
            var a = new ObjectId(validSha1);
            var b = new ObjectId(validSha1);

            Assert.True((a.Equals(b)));
            Assert.True((b.Equals(a)));

            Assert.True((a == b));
            Assert.False((a != b));
        }
        public void DifferentObjectIdsAreEqual()
        {
            var a = new ObjectId(validSha1);
            var b = new ObjectId(validSha2);

            Assert.False((a.Equals(b)));
            Assert.False((b.Equals(a)));

            Assert.False((a == b));
            Assert.True((a != b));
        }
Example #34
0
		public bool CanLoot(ObjectId looterID) {
			bool youCanLootMe = true;
			if (looterID.Equals(((IActor)this).KillerID.Pid)) {
				if (DateTime.UtcNow < ((IActor)this).TimeOfDeath.AddSeconds(30)) {
					youCanLootMe = false;
				}
			}

			return youCanLootMe;
		}
Example #35
0
        public Tuple<PackObjectType, byte[]> ReadObject(ObjectId objId)
        {
            long? offset = TryGetOffset(objId);
            if (!offset.HasValue)
                throw new Exception("Object id not found.");

            var ret = ReadObject(offset.Value);

            //check hash
            string header = string.Format(CultureInfo.InvariantCulture, "{0} {1}\0",
                ret.Item1.ToString().ToLowerInvariant(), ret.Item2.Length);
            byte[] headerBytes = Encoding.ASCII.GetBytes(header);
            var sha = SHA1.Create();
            sha.TransformBlock(headerBytes, 0, headerBytes.Length, null, 0);
            sha.TransformFinalBlock(ret.Item2, 0, ret.Item2.Length);
            var hash = new ObjectId(sha.Hash);
            if (!hash.Equals(objId))
                throw new Exception("Object from pack file does not have the right hash.");

            return ret;
        }