Пример #1
0
        public void OneUpdateWithPatchVersionChange()
        {
            var updates = UpdateSetForNewVersion(NewPackageFooBar("1.1.9"), MakePackageForV110());

            var report = CommitWording.MakeCommitDetails(updates);

            Assert.That(report, Does.StartWith("NuKeeper has generated a patch update of `foo.bar` to `1.1.9` from `1.1.0"));
        }
Пример #2
0
        public void OneUpdate_MakeCommitDetails_HasVersionInfo()
        {
            var updates = UpdateSetFor(MakePackageForV110());

            var report = CommitWording.MakeCommitDetails(updates);

            Assert.That(report, Does.StartWith("NuKeeper has generated a minor update of `foo.bar` to `1.2.3` from `1.1.0`"));
        }
Пример #3
0
        public void OneUpdate_MakeCommitDetails_HasVersionLimitData()
        {
            var updates = UpdateSetForLimited(MakePackageForV110());

            var report = CommitWording.MakeCommitDetails(updates);

            Assert.That(report, Does.Contain("There is also a higher version, `foo.bar 2.3.4`, but this was not applied as only `Minor` version changes are allowed."));
        }
Пример #4
0
        public void TwoUpdatesSameVersion_MakeCommitDetails_HasStandardTexts()
        {
            var updates = UpdateSetFor(MakePackageForV110(), MakePackageForV110InProject3());

            var report = CommitWording.MakeCommitDetails(updates);

            AssertContainsStandardText(report);
        }
Пример #5
0
        public void OneUpdate_MakeCommitDetails_HasStandardTexts()
        {
            var updates = UpdateSetFor(MakePackageForV110());

            var report = CommitWording.MakeCommitDetails(updates);

            AssertContainsStandardText(report);
        }
Пример #6
0
        public void OneUpdate_MakeCommitDetails_HasPublishedDate()
        {
            var updates = UpdateSetFor(MakePackageForV110());

            var report = CommitWording.MakeCommitDetails(updates);

            Assert.That(report, Does.Contain("`foo.bar 1.2.3` was published at `2018-02-19T11:12:07Z`"));
        }
Пример #7
0
        public void OneUpdateWithPatchVersionChange()
        {
            var updates = PackageUpdates.ForNewVersion(new PackageIdentity("foo.bar", new NuGetVersion("1.1.9")), MakePackageForV110())
                          .InList();

            var report = CommitWording.MakeCommitDetails(updates);

            Assert.That(report, Does.StartWith("NuKeeper has generated a patch update of `foo.bar` to `1.1.9` from `1.1.0"));
        }
Пример #8
0
        public void TwoUpdatesSameVersion_MakeCommitDetails_HasVersionInfo()
        {
            var updates = PackageUpdates.For(MakePackageForV110(), MakePackageForV110InProject3())
                          .InList();

            var report = CommitWording.MakeCommitDetails(updates);

            Assert.That(report, Does.StartWith("NuKeeper has generated a minor update of `foo.bar` to `1.2.3` from `1.1.0`"));
        }
Пример #9
0
        public void OneUpdate_MakeCommitDetails_IsNotEmpty()
        {
            var updates = UpdateSetFor(MakePackageForV110());

            var report = CommitWording.MakeCommitDetails(updates);

            Assert.That(report, Is.Not.Null);
            Assert.That(report, Is.Not.Empty);
        }
Пример #10
0
        public void TwoUpdates_MakeCommitDetails_HasVersionInfo()
        {
            var updates = UpdateSetFor(MakePackageForV110(), MakePackageForV100());

            var report = CommitWording.MakeCommitDetails(updates);

            Assert.That(report, Does.StartWith("NuKeeper has generated a minor update of `foo.bar` to `1.2.3`"));
            Assert.That(report, Does.Contain("2 versions of `foo.bar` were found in use: `1.1.0`, `1.0.0`"));
        }
Пример #11
0
        public void OneUpdateWithInternalPackageSource()
        {
            var updates = UpdateSetForInternalSource(MakePackageForV110());

            var report = CommitWording.MakeCommitDetails(updates);

            Assert.That(report, Does.Not.Contain("on NuGet.org"));
            Assert.That(report, Does.Not.Contain("www.nuget.org"));
        }
Пример #12
0
        public void TwoUpdatesSameVersion_MakeCommitDetails_NotEmpty()
        {
            var updates = UpdateSetFor(MakePackageForV110(), MakePackageForV110InProject3());

            var report = CommitWording.MakeCommitDetails(updates);

            Assert.That(report, Is.Not.Null);
            Assert.That(report, Is.Not.Empty);
        }
Пример #13
0
        public void TwoUpdates_MakeCommitDetails_HasStandardTexts()
        {
            var updates = UpdateSetFor(MakePackageForV110(), MakePackageForV100());

            var report = CommitWording.MakeCommitDetails(updates);

            AssertContainsStandardText(report);
            Assert.That(report, Does.Contain("1.0.0"));
        }
Пример #14
0
        public void OneUpdate_MakeCommitDetails_HasProjectDetails()
        {
            var updates = UpdateSetFor(MakePackageForV110());

            var report = CommitWording.MakeCommitDetails(updates);

            Assert.That(report, Does.Contain("1 project update:"));
            Assert.That(report, Does.Contain("Updated `folder\\src\\project1\\packages.config` to `foo.bar` `1.2.3` from `1.1.0`"));
        }
Пример #15
0
        public void OneUpdateWithDate_MakeCommitDetails_HasVersionLimitDataWithDate()
        {
            var publishedAt = new DateTimeOffset(2018, 2, 20, 11, 32, 45, TimeSpan.Zero);
            var updates     = UpdateSetForLimited(publishedAt, MakePackageForV110());

            var report = CommitWording.MakeCommitDetails(updates);

            Assert.That(report, Does.Contain("There is also a higher version, `foo.bar 2.3.4` published at `2018-02-20T11:32:45Z`,"));
            Assert.That(report, Does.Contain(" ago, but this was not applied as only `Minor` version changes are allowed."));
        }
Пример #16
0
        public void TwoUpdatesSameVersion_MakeCommitDetails_HasProjectList()
        {
            var updates = UpdateSetFor(MakePackageForV110(), MakePackageForV110InProject3());

            var report = CommitWording.MakeCommitDetails(updates);

            Assert.That(report, Does.Contain("2 project updates:"));
            Assert.That(report, Does.Contain("Updated `folder\\src\\project1\\packages.config` to `foo.bar` `1.2.3` from `1.1.0`"));
            Assert.That(report, Does.Contain("Updated `folder\\src\\project3\\packages.config` to `foo.bar` `1.2.3` from `1.1.0`"));
        }
Пример #17
0
        public void TwoUpdates_MakeCommitDetails_NotEmpty()
        {
            var updates = PackageUpdates.For(MakePackageForV110(), MakePackageForV100())
                          .InList();

            var report = CommitWording.MakeCommitDetails(updates);

            Assert.That(report, Is.Not.Null);
            Assert.That(report, Is.Not.Empty);
        }
Пример #18
0
        public void OneUpdateWithMinorVersionChange()
        {
            var updates = new List <PackageUpdateSet>
            {
                UpdateSetForNewVersion(NewPackageFooBar("1.2.1"), MakePackageForV110())
            };

            var report = CommitWording.MakeCommitDetails(updates);

            Assert.That(report, Does.StartWith("NuKeeper has generated a minor update of `foo.bar` to `1.2.1` from `1.1.0"));
        }
Пример #19
0
        private async Task <int> MakeUpdatePullRequests(
            IGitDriver git, RepositoryData repository,
            NuGetSources sources, SettingsContainer settings,
            IReadOnlyCollection <PackageUpdateSet> updates)
        {
            _logger.Normal(UpdatesLogger.OldVersionsToBeUpdated(updates));

            git.Checkout(repository.DefaultBranch);

            // branch
            var branchWithChanges = BranchNamer.MakeName(updates);

            _logger.Detailed($"Using branch name: '{branchWithChanges}'");
            git.CheckoutNewBranch(branchWithChanges);

            foreach (var updateSet in updates)
            {
                await _updateRunner.Update(updateSet, sources);

                var commitMessage = CommitWording.MakeCommitMessage(updateSet);
                git.Commit(commitMessage);
            }

            git.Push(repository.Remote, branchWithChanges);

            var title = CommitWording.MakePullRequestTitle(updates);
            var body  = CommitWording.MakeCommitDetails(updates);

            string qualifiedBranch;

            if (repository.Pull.Owner == repository.Push.Owner)
            {
                qualifiedBranch = branchWithChanges;
            }
            else
            {
                qualifiedBranch = repository.Push.Owner + ":" + branchWithChanges;
            }

            var pullRequestRequest = new PullRequestRequest(qualifiedBranch, title, repository.DefaultBranch)
            {
                Body = body
            };

            await _collaborationFactory.CollaborationPlatform.OpenPullRequest(repository.Pull, pullRequestRequest, settings.SourceControlServerSettings.Labels);


            git.Checkout(repository.DefaultBranch);
            return(updates.Count);
        }
Пример #20
0
        public void TwoUpdateSets()
        {
            var packageTwo = new PackageIdentity("packageTwo", new NuGetVersion("3.4.5"));

            var updates = new List <PackageUpdateSet>
            {
                UpdateSetForNewVersion(NewPackageFooBar("2.1.1"), MakePackageForV110()),
                UpdateSetForNewVersion(packageTwo, MakePackageForV110("packageTwo"))
            };

            var report = CommitWording.MakeCommitDetails(updates);

            Assert.That(report, Does.StartWith("2 packages were updated: `foo.bar`, `packageTwo`"));
            Assert.That(report, Does.Contain("NuKeeper has generated a major update of `foo.bar` to `2.1.1` from `1.1.0`"));
            Assert.That(report, Does.Contain("NuKeeper has generated a major update of `packageTwo` to `3.4.5` from `1.1.0`"));
        }
Пример #21
0
        private async Task MakeGitHubPullRequest(
            PackageUpdateSet updates,
            RepositoryData repository,
            string title, string branchWithChanges)
        {
            string qualifiedBranch;

            if (repository.Pull.Owner == repository.Push.Owner)
            {
                qualifiedBranch = branchWithChanges;
            }
            else
            {
                qualifiedBranch = repository.Push.Owner + ":" + branchWithChanges;
            }

            var pr = new NewPullRequest(title, qualifiedBranch, repository.DefaultBranch)
            {
                Body = CommitWording.MakeCommitDetails(updates)
            };

            await _github.OpenPullRequest(repository.Pull, pr);
        }