Ejemplo n.º 1
0
        private RebaseStatus CompleteStep(IRepository repository)
        {
            var transformations = new TransformationFromChunkChanges(_rebase.ModifiedProperties, _rebase.AddedObjects, _rebase.DeletedObjects);
            var transformed     = CurrentTransformedRepository.DataAccessor.With(CurrentTransformedRepository, transformations);

            transformed.SetRepositoryData(CurrentTransformedRepository.RepositoryDescription, ObjectId.Zero);
            _rebase.Transformations.Add(transformed);

            _rebase.ClearChanges();
            _rebase.CompletedStepCount++;

            if (_rebase.CompletedStepCount != _rebase.TotalStepCount)
            {
                return(ContinueNext(repository));
            }
            else
            {
                return(CompleteRebase(repository));
            }
        }
Ejemplo n.º 2
0
        internal (CherryPickStatus Status, IObjectRepository Result) Complete(IRepository repository)
        {
            if (_cherryPick.ModifiedProperties.Any(c => c.IsInConflict))
            {
                throw new GitObjectDbException("There are remaining unresolved conflicts.");
            }

            var transformations = new TransformationFromChunkChanges(_cherryPick.ModifiedProperties, _cherryPick.AddedObjects, _cherryPick.DeletedObjects);
            var transformed     = _cherryPick.Repository.DataAccessor.With(_cherryPick.Repository, transformations);

            transformed.SetRepositoryData(_cherryPick.Repository.RepositoryDescription, ObjectId.Zero);

            var computeChanges   = _computeTreeChangesFactory(_cherryPick.Repository.Container, _cherryPick.Repository.RepositoryDescription);
            var lastCommit       = repository.Lookup <Commit>(_cherryPick.HeadCommitId);
            var cherryPickCommit = repository.Lookup <Commit>(_cherryPick.CherryPickCommitId);
            var changes          = computeChanges.Compare(_cherryPick.Repository, transformed.Repository);

            if (changes.Any())
            {
                var definition = TreeDefinition.From(lastCommit);
                repository.UpdateTreeDefinition(changes, definition, _serializer, lastCommit);
                var tree = repository.ObjectDatabase.CreateTree(definition);
                lastCommit = repository.ObjectDatabase.CreateCommit(cherryPickCommit.Author, cherryPickCommit.Committer, cherryPickCommit.Message, tree, new[] { lastCommit }, false);
            }

            var logMessage = lastCommit.BuildCommitLogMessage(false, false, false);

            repository.UpdateHeadAndTerminalReference(lastCommit, logMessage);
            var result = default(IObjectRepository);

            if (_cherryPick.Repository.Container is ObjectRepositoryContainer container)
            {
                result = container.ReloadRepository(_cherryPick.Repository, lastCommit.Id);
            }
            return(CherryPickStatus.CherryPicked, result);
        }