예제 #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();
            }
        }
 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
 public APILibrariesPage(Hg samples)
 {
     Samples = samples;
 }