コード例 #1
0
        public void EnumeratePullRequestActivities_ExistingPublicPullRequest_ReturnValidInfo()
        {
            var activities = ExistingPullRequest.EnumeratePullRequestActivities();

            activities.ShouldNotBeNull();
            activities.ShouldNotBeEmpty();
        }
コード例 #2
0
        public async Task EnumeratePullRequestCommitsAsync_ExistingPublicPullRequest_ReturnValidInfo()
        {
            var commits = ExistingPullRequest.EnumeratePullRequestCommitsAsync();

            commits.ShouldNotBeNull();
            (await commits.ToListAsync()).ShouldNotBeEmpty();
        }
コード例 #3
0
        public async Task GetDiffForPullRequestAsync_ExistingPublicPullRequest_ReturnValidInfo()
        {
            var diff = await ExistingPullRequest.GetDiffForPullRequestAsync();

            diff.ShouldNotBeNull();
            diff.ShouldBe("diff -r 0fbcabe523bc -r 4f9cfa6003cb contrib/hg-ssh\n--- a/contrib/hg-ssh\n+++ b/contrib/hg-ssh\n@@ -25,8 +25,8 @@\n You can use pattern matching of your normal shell, e.g.:\n command=\"cd repos && hg-ssh user/thomas/* projects/{mercurial,foo}\"\n \n-You can also add a --read-only flag to allow read-only access to a key, e.g.:\n-command=\"hg-ssh --read-only repos/*\"\n+You can also add a --read-only flag to allow read-only access to a repo, e.g.:\n+command=\"hg-ssh repo1 --read-only=repo2 repo3\"\n \"\"\"\n \n # enable importing on demand to reduce startup time\n@@ -34,21 +34,16 @@\n \n from mercurial import dispatch\n \n-import sys, os, shlex\n+import sys, optparse, os, shlex\n \n def main():\n+    parser = optparse.OptionParser()\n+    parser.add_option('--read-only', action='append', default=[])\n+    options, args = parser.parse_args()\n     cwd = os.getcwd()\n-    readonly = False\n-    args = sys.argv[1:]\n-    while len(args):\n-        if args[0] == '--read-only':\n-            readonly = True\n-            args.pop(0)\n-        else:\n-            break\n     allowed_paths = [os.path.normpath(os.path.join(cwd,\n                                                    os.path.expanduser(path)))\n-                     for path in args]\n+                     for path in args + options.read_only]\n     orig_cmd = os.getenv('SSH_ORIGINAL_COMMAND', '?')\n     try:\n         cmdargv = shlex.split(orig_cmd)\n@@ -61,7 +56,7 @@\n         repo = os.path.normpath(os.path.join(cwd, os.path.expanduser(path)))\n         if repo in allowed_paths:\n             cmd = ['-R', repo, 'serve', '--stdio']\n-            if readonly:\n+            if path in options.read_only:\n                 cmd += [\n                     '--config',\n                     'hooks.prechangegroup.hg-ssh=python:__main__.rejectpush',\n");
        }
コード例 #4
0
        public void GetPullRequestComment_ExistingCommentOnAPublicPullRequest_ReturnValidInfo()
        {
            var comment = ExistingPullRequest.GetPullRequestComment(53789);

            comment.ShouldBeFilled();
            comment.content.raw.ShouldBe("This repo is not used for development, it's just a mirror (and I am just an infrequent contributor). Please consult http://mercurial.selenic.com/wiki/ContributingChanges and send your patch to ``mercurial-devel`` ML.");
        }
コード例 #5
0
        public void EnumeratePullRequestCommits_ExistingPublicPullRequest_ReturnValidInfo()
        {
            var commits = ExistingPullRequest.EnumeratePullRequestCommits();

            commits.ShouldNotBeNull();
            commits.ShouldNotBeEmpty();
        }
コード例 #6
0
        public void GetPullRequestComment_NotExistingCommentOnPublicPullRequest_ReturnEmpty()
        {
            var comment = ExistingPullRequest.GetPullRequestComment(int.MaxValue);

            comment.ShouldNotBeNull();
            comment.id.ShouldBeNull();
        }
コード例 #7
0
        public async Task EnumeratePullRequestActivitiesAsync_ExistingPublicPullRequest_ReturnValidInfo()
        {
            var activities = ExistingPullRequest.EnumeratePullRequestActivitiesAsync();

            activities.ShouldNotBeNull();
            (await activities.ToListAsync()).ShouldNotBeEmpty();
        }
コード例 #8
0
        public void GetDiffForPullRequest_ExistingPublicPullRequest_ReturnValidInfo()
        {
            var diff = ExistingPullRequest.GetDiffForPullRequest();

            diff.ShouldNotBeNull();
            // TODO: to complete once the right POCO will be returned
        }
コード例 #9
0
        public async Task GetDiffForPullRequestAsync_ExistingPullRequest_ReturnValidInfo()
        {
            var diff = await ExistingPullRequest.GetDiffForPullRequestAsync();

            diff.ShouldNotBeNull();
            diff.ShouldStartWith("diff ");
        }
コード例 #10
0
        public void GetDiffForPullRequest_ExistingPullRequest_ReturnValidInfo()
        {
            var diff = ExistingPullRequest.GetDiffForPullRequest();

            diff.ShouldNotBeNull();
            diff.ShouldStartWith("diff ");
        }
コード例 #11
0
        public void ListPullRequestActivities_ExistingPublicPullRequest_ReturnValidInfo()
        {
            var activities = ExistingPullRequest.ListPullRequestActivities();

            activities.ShouldNotBeNull();
            activities.Count.ShouldBe(4);
            activities[0].update.state.ShouldBe("DECLINED");
        }
コード例 #12
0
        public void ListPullRequestCommits_ExistingPublicPullRequest_ReturnValidInfo()
        {
            var commits = ExistingPullRequest.ListPullRequestCommits();

            commits.ShouldNotBeNull();
            commits.Count.ShouldBe(2);
            commits[0].message.ShouldBe("Update the docstring");
        }
コード例 #13
0
        public void ListPullRequestComments_ExistingPublicPullRequest_ReturnValidInfo()
        {
            var comments = ExistingPullRequest.ListPullRequestComments();

            comments.ShouldNotBeNull();
            comments.Count.ShouldBe(2);
            comments[0].content.raw.ShouldBe("This repo is not used for development, it's just a mirror (and I am just an infrequent contributor). Please consult http://mercurial.selenic.com/wiki/ContributingChanges and send your patch to ``mercurial-devel`` ML.");
        }
コード例 #14
0
        public async Task GetPullRequestAsync_ExistingPublicPullRequest_ReturnValidInfo()
        {
            var pullRequest = await ExistingPullRequest.GetPullRequestAsync();

            pullRequest.ShouldNotBeNull();
            pullRequest.id.ShouldBe(2);
            pullRequest.author?.nickname.ShouldBe("goodtune");
            pullRequest.title.ShouldBe("Selective read/write or read-only repos with hg-ssh");
            pullRequest.state.ShouldBe("DECLINED");
        }
コード例 #15
0
        public void GetPullRequest_ExistingPublicPullRequest_ReturnValidInfo()
        {
            var pullRequest = ExistingPullRequest.GetPullRequest();

            pullRequest.ShouldNotBeNull();
            pullRequest.id.ShouldBe(2);
            pullRequest.author?.username.ShouldBe("goodtune");
            pullRequest.title.ShouldBe("Selective read/write or read-only repos with hg-ssh");
            pullRequest.state.ShouldBe("DECLINED");
        }
コード例 #16
0
        public void GetPullRequestComment_NotExistingCommentOnPublicPullRequest_ThrowException()
        {
            var exception = Assert.Throws <BitbucketV2Exception>(() => ExistingPullRequest.GetPullRequestComment(int.MaxValue));

            exception.HttpStatusCode.ShouldBe(HttpStatusCode.NotFound);
        }