コード例 #1
0
        static void Main(string[] args)
        {
            CommandLine.DisplayGoogleSampleHeader("Update Wiki");
            CommandLine.EnableExceptionHandling();

            using (Hg wiki = Hg.Clone("https://code.google.com/p/google-api-dotnet-client.wiki/"))
                using (Hg samples = Hg.Clone("https://code.google.com/p/google-api-dotnet-client.samples/"))
                {
                    // Make all the changes.
                    UpdateWiki(wiki, samples, null, null);

                    // Show them to the user.
                    CommandLine.WriteAction("Opening modified working directory ...");

                    if (!wiki.HasUncommitedChanges)
                    {
                        CommandLine.WriteAction("No changes detected.");
                        CommandLine.PressAnyKeyToExit();
                    }
                    else
                    {
                        CommandLine.WriteAction("Showing diff ...");
                        wiki.ShowDiff();
                        Process.Start(wiki.WorkingDirectory);

                        if (CommandLine.RequestUserChoice("Do you want to push these changes to the server?"))
                        {
                            wiki.Commit("Updated the generated section of the APILibraries.wiki.");
                            wiki.Push();
                        }
                    }
                }
        }
コード例 #2
0
        /// <summary> Checks out all repositories. </summary>
        private static void CheckoutRepositories()
        {
            CommandLine.WriteLine("{{white}} =======================================");
            CommandLine.WriteLine("{{white}} Checking out repositories");
            CommandLine.WriteLine("{{white}} =======================================");
            const string URL = "https://code.google.com/p/google-api-dotnet-client{0}/";

            if (Arguments.UseLocalRepository)
            {
                CommandLine.WriteAction("Using local Default repository. This won't release!");
                Default = Hg.Get("../../../../../", string.Format(URL, ""));
            }
            else
            {
                Default = Hg.Get("default", string.Format(URL, ""));
                if (BuildVersion != 0)
                {
                    Default.Update(string.Format("{0}.{1}", MajorVersion, MinorVersion));
                }
            }

            Samples         = Hg.Get("samples", string.Format(URL, ".samples"));
            Wiki            = Hg.Get("wiki", string.Format(URL, ".wiki"));
            Contrib         = Hg.Get("contrib", string.Format(URL, ".contrib"));
            AllRepositories = new[] { Default, Wiki, Contrib, Samples };

            CommandLine.WriteLine();
        }
コード例 #3
0
        /// <summary> Set the default Mercurial installation. Must be called for all other methods to work. </summary>
        public void SetDefault(Hg hgDefault)
        {
            Hg.Default = hgDefault;

            // This allows SF to intercept some Hg commands involving registration codes
            Hg.DefaultRunnerCreationFunc = (installPathArg, repositoryArg, mergePathArg) =>
                                           new SFHgRunner(installPathArg, repositoryArg, mergePathArg);
        }
コード例 #4
0
        private static string GetOriginalFileName(string fileName)
        {
            if (VisualHgFileStatus.Matches(fileName, HgFileStatus.Renamed | HgFileStatus.Copied))
            {
                return(Hg.GetRenamedFileOriginalName(fileName));
            }

            return(fileName);
        }
コード例 #5
0
 public void DetectsRepositoryTheCheapWay()
 {
     using (var repoDirectory = new SelfCleaningDirectory())
     {
         var hg = new Hg(new HgProcess(), new HgXmlLogParser(), repoDirectory.Path);
         Assert.That(hg.IsRepository, Is.False);
         Directory.CreateDirectory(Path.Combine(repoDirectory.Path, ".hg"));
         Assert.That(hg.IsRepository);
     }
 }
コード例 #6
0
 static void GUITest_BadCommand()
 {
     if (VersionControl.versionControlType == VersionControlType.Git)
     {
         UVCProcessPopup.Init(Git.RunGit("notarealcommand", CommandLine.EmptyHandler), false, true, null, false);
     }
     else
     {
         UVCProcessPopup.Init(Hg.RunHg("notarealcommand", CommandLine.EmptyHandler), false, true, null, false);
     }
 }
コード例 #7
0
 static void CoreTest_BadCommand()
 {
     if (VersionControl.versionControlType == VersionControlType.Git)
     {
         Git.RunGit("notarealcommand", OnProcessExit);
     }
     else
     {
         Hg.RunHg("notarealcommand", OnProcessExit);
     }
 }
コード例 #8
0
        public void Update(string root)
        {
            if (String.IsNullOrEmpty(root))
            {
                return;
            }

            lock (SyncRoot)
            {
                items[root] = Hg.GetCurrentBranchName(root);
            }
        }
コード例 #9
0
        /// <summary>
        /// Updates the Wiki
        /// </summary>
        public static void UpdateWiki(Hg wiki, Hg samples, string releaseNotes, string zipDir)
        {
            // Make the changes.
            CommandLine.WriteAction("Updating 'APILibraries.wiki' ...");
            new APILibrariesPage(samples).InsertIntoFile(Path.Combine(wiki.WorkingDirectory, "APIs.wiki"));

            if (releaseNotes != null)
            {
                CommandLine.WriteAction("Updating 'Downloads.wiki' ...");
                new DownloadsPage(releaseNotes, zipDir).InsertIntoFile(
                    Path.Combine(wiki.WorkingDirectory, "Downloads.wiki"));
            }
        }
コード例 #10
0
 public void VersionNaughtDotNaughtReturnedWhenVersionTextNotFound()
 {
     var processMock = new Mock<IHgProcess>();
     processMock
         .Setup(p => p.Execute(It.IsAny<HgArguments>()))
         .Returns(new HgResult(false, "I have no idea what you're talking about.", ""))
         .AtMostOnce()
         .Verifiable();
     using (var repoDirectory = new SelfCleaningDirectory())
     {
         var hg = new Hg(processMock.Object, new HgXmlLogParser(), repoDirectory.Path);
         var actual = hg.Version;
         Assert.That(actual, Is.EqualTo(new Version(0, 0)));
     }
 }
コード例 #11
0
        /// <summary>The main release logic for creating a new release of Google.Apis.</summary>
        private void Run()
        {
            DefaultRepository = new Hg(new Uri(string.Format(CloneUrlFormat, "")), options.IsLocal ? null : "default");

            // Step 1 is only for creating the core Google.Apis packages.
            if (options.Step == 1)
            {
                DoStep1();
            }
            // Step 2 should be done after the NuGet publisher generated all the APIs and the samples repository was
            // updated with the new packages
            else if (options.Step == 2)
            {
                DoStep2();
            }
        }
コード例 #12
0
 public void CurrentBranchFunctionsAsDesigned()
 {
     var expected = new Branch("differenty");
     using (var repoDirectory = new SelfCleaningDirectory())
     {
         InitializeRepository(repoDirectory);
         Enumerable.Range(1, 5).ToList().ForEach(i => AddRandomCommit(repoDirectory));
         ChangeToBranch(repoDirectory, expected);
         Enumerable.Range(1, 5).ToList().ForEach(i => AddRandomCommit(repoDirectory));
         var provider = new Hg(DefaultProcessExecutor, _defaultXmlLogParser, repoDirectory.Path);
         provider.Update(Branch.Default.AsTag().AsRevision());
         Assert.That(provider.CurrentBranch, Is.EqualTo(Branch.Default));
         provider.Update(expected.AsTag().AsRevision());
         Assert.That(provider.CurrentBranch, Is.EqualTo(expected));
     }
 }
コード例 #13
0
 public void VersionFindsAnyVersionyLookingThingInFirstLine()
 {
     var processMock = new Mock<IHgProcess>();
     processMock
         .Setup(p => p.Execute(It.IsAny<HgArguments>()))
         .Returns(new HgResult(false,
                               "I have no idea what you're talking about, but version 51.50.\r\nMaybe you mean version 19.84?",
                               ""))
         .AtMostOnce()
         .Verifiable();
     using (var repoDirectory = new SelfCleaningDirectory())
     {
         var hg = new Hg(processMock.Object, new HgXmlLogParser(), repoDirectory.Path);
         var actual = hg.Version;
         Assert.That(actual, Is.EqualTo(new Version(51, 50)));
     }
 }
コード例 #14
0
        public static void ShowDiffWindow(string fileName)
        {
            var root   = HgPath.FindRepositoryRoot(fileName);
            var parent = GetOriginalFileName(fileName);

            var temp     = Hg.CreateParentRevisionTempFile(parent, root);
            var revision = Hg.GetParentRevision(root) ?? "(parent revision)";

            var tempName = GetDisplayName(parent, revision, root);
            var name     = GetDisplayName(fileName, root);

            var diffTool = GetDiffTool();

            diffTool.Exited += (s, e) => DeleteFile(temp);

            try
            {
                diffTool.Start(temp, fileName, tempName, name, root);
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show(Resources.DiffToolNotFound + "\n\n" + diffTool.FileName, Resources.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #15
0
        /// <summary>
        /// Doing Step 2 of the release process which includes the following:
        /// <list type="number">
        /// <item><description>Builds samples</description></item>
        /// <item><description>Creates a release notes</description></item>
        /// <item><description>Update wiki download page</description></item>
        /// <item><description>Create a new release in the contrib repository</description></item>
        /// <item><description>Commits, Tags and Pushes</description></item>
        /// </list>
        /// </summary>
        private void DoStep2()
        {
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("=========================");
            Console.WriteLine("Prerequisites for Step 2:");
            Console.WriteLine("You ran Step 1.");
            Console.WriteLine("You upgraded the Google.Apis NuGet packages for each sample in the samples " +
                              "repository and pushed that change.");
            Console.WriteLine("=========================");
            if (!CanContinue())
            {
                return;
            }

            SamplesRepository = new Hg(new Uri(string.Format(CloneUrlFormat, ".samples")), "samples");
            WikiRepository    = new Hg(new Uri(string.Format(CloneUrlFormat, ".wiki")), "wiki");
            ContribRepository = new Hg(new Uri(string.Format(CloneUrlFormat, ".contrib")), "contrib");

            // if there are incoming changes those changes will be printed, otherwise we can continue in the
            // process
            if (!HasIncomingChanges(AllRepositories))
            {
                BuildSamples();
                var notes = CreateContribNewRelease();
                UpdateWiki(notes);

                foreach (var repository in AllRepositories)
                {
                    repository.AddRemoveFiles();
                }

                Console.WriteLine("=========================");
                Console.WriteLine("Commit, Tag and Push");
                Console.WriteLine("=========================");
                if (!CanContinue())
                {
                    return;
                }

                // commit
                CommitAndTag();

                // push
                foreach (Hg repository in AllRepositories)
                {
                    repository.Push();
                }

                // create branch
                PrintCreateBranch();

                // publish core components to NuGet
                if (!string.IsNullOrEmpty(options.NuGetApiKey))
                {
                    PublishPackagesToNuGet();
                    Console.WriteLine("Now... you should run the NuGet publisher to publish a new PCL "
                                      + "for each generated Google API. Run: " +
                                      "Google.Apis.NuGet.Publisher --all_apis true -m publisher -k [NUGET_KEY]");
                }
                else
                {
                    TraceSource.TraceEvent(TraceEventType.Error, "NuGet API key is empty!");
                }
            }
        }
コード例 #16
0
ファイル: APILibrariesPage.cs プロジェクト: artzub/LoggenCSG
 public APILibrariesPage(Hg samples)
 {
     Samples = samples;
 }