public FaultyVersion GetFaultyVersion()
        {
            List <FaultyFile> faultyFiles = HelperFunctions.GetFaultyFiles(FaultyFilesData);

            if (faultyFiles is null)
            {
                return(null);
            }
            // If there are two parents, the commit is a merge commit. The first parent is the master branch, where the second parent is the actual fix.
            // We want to run our metrics on the master branch, not the version with the fix. Therefore, we take the first parent.
            return(new FaultyVersion(Parents.First().Hash, faultyFiles, Hash));
        }
Example #2
0
        public void SetTopmostParent(List <WrittenTrait> plainTraits)
        {
            if (Parents.Count == 0)
            {
                TopmostParent = ID;
                return;
            }
            var idOfParent = Parents.First();

            while (plainTraits.Find(x => x.ID == idOfParent).Parents.Count > 0)
            {
                List <int> parents = plainTraits.Find(x => x.ID == idOfParent).Parents;
                idOfParent = parents.First();
            }
            TopmostParent     = idOfParent;
            TopmostParentName = plainTraits.Find(x => x.ID == TopmostParent).Name;
        }
        protected override void OnStateUpdated(ViewStates state)
        {
            if (this._parentsRetriever == null) //this function may endups being called before instance is fully constructed
            {
                return;
            }

            var parent = this.RetrieveParent(this.CurrentItem);

            if (State == ViewStates.Creating ||
                State == ViewStates.UpdatingCreate ||
                State == ViewStates.UpdatingViewing ||
                State == ViewStates.Updating)
            {
                Parents = this._parentsRetriever();
            }

            if (parent != null && Parents.Count() > 0)
            {
                var itemParent = Parents.First(cat => cat.Id.Equals(parent.Id));
                this.SetParent(this.CurrentItem, itemParent);
            }
        }