GitHub PullRequestReviewCommentEvent at 2014-02-11 00:22:15
Repository: tagz
Actor: cvan
Payload: {"comment":{"url":"https://api.github.com/repos/cvan/tagz/pulls/comments/9609163","id":9609163,"diff_hunk":"@@ -0,0 +1,210 @@\n+#!/usr/bin/env python\n+\"\"\"\n+This is a script to automatically tag repos on GitHub™.\n+\n+Sample usage:\n+\n+* To create a tag:\n+\n+    $ python tagz.py -r mozilla/fireplace -c create -t 2014.02.11\n+\n+* To create multiple tags:\n+\n+    $ python tagz.py -r mozilla/fireplace,mozilla/zamboni -c create -t 2014.02.11\n+\n+* To delete a tag:\n+\n+    $ python tagz.py -r mozilla/fireplace -c delete -t 2014.02.11\n+\n+* To cherry-pick a commit onto a tag:\n+\n+    $ python tagz.py -r mozilla/fireplace -c cherrypick -t 2014.02.11 -s b4dc0ffee\n+\n+* To remove a commit from a tag:\n+\n+    $ python tagz.py -r mozilla/fireplace -c revert -t 2014.02.11 -s b4dc0ffee\n+\n+\"\"\"\n+\n+import os\n+import subprocess\n+\n+import argparse\n+\n+\n+GIT_ROOT_PATH = '/tmp/'\n+VERBOSE = False\n+\n+\n+def _open_pipe(cmd, cwd=None):\n+    return subprocess.Popen(cmd, stdin=subprocess.PIPE,\n+                            stdout=subprocess.PIPE,\n+                            stderr=subprocess.PIPE, cwd=cwd)\n+\n+\n+def get_team_repo(remote_url):\n+    \"\"\"\n+    Takes remote URL (e.g., `git@github.com:mozilla/fireplace.git`) and\n+    returns team/repo pair (e.g., `mozilla/fireplace`).\n+\n+    \"\"\"\n+    if ':' not in remote_url:\n+        return remote_url\n+    return remote_url.split(':')[1].replace('.git', '')\n+\n+\n+def get_remote_url(remote_url):\n+    \"\"\"\n+    Takes a GitHub remote URL (e.g., `mozilla/fireplace`) and\n+    returns full remote URL (e.g., `git@github.com:mozilla/fireplace.git`).\n+\n+    \"\"\"\n+    if ':' not in remote_url:\n+        remote_url = 'git@github.com:' + remote_url\n+    if not remote_url.endswith('.git'):\n+        remote_url += '.git'\n+    return remote_url\n+\n+\n+def git_path(remote_url):\n+    repo = ''.join(x for x in get_team_repo(remote_url)\n+                   if x.isalnum() or x == '/')\n+    dir_name = os.path.join(GIT_ROOT_PATH, repo.replace('/', '__'))\n+    if not os.path.exists(dir_name):\n+        os.makedirs(dir_name)\n+        git(dir_name,\n+            'clone {remote_url} {dir_name}'.format(remote_url=remote_url,\n+                                                   dir_name=dir_name))\n+    return dir_name\n+\n+\n+def git(path, args):\n+    stdout, stderr = _open_pipe(['git'] + args.split(' '),\n+                                cwd=path).communicate()\n+    if VERBOSE and stderr:\n+        print stderr\n+    return stderr or stdout\n+\n+\n+def github_url(team, repo, url=None):\n+    return 'http://github.com/{team}/{repo}{url}'.format(\n+        team=team, repo=repo, url=url or '')\n+\n+\n+def pbcopy(data):\n+    \"\"\"Copy to clipboard on Mac OS X.\"\"\"","path":"tagz.py","position":95,"original_position":95,"commit_id":"8cf6e0bfba7618d49f49bd6d1d59077b8dbbeb55","original_commit_id":"8cf6e0bfba7618d49f49bd6d1d59077b8dbbeb55","user":{"login":"cvan","id":203725,"avatar_url":"https://gravatar.com/avatar/47de0e6948b289c9b4b4be0d6d66c0f4?d=https%3A%2F%2Fidenticons.github.com%2Fe8d88d4bdf0c8bb9968e62c64a9d8df1.png&r=x","gravatar_id":"47de0e6948b289c9b4b4be0d6d66c0f4","url":"https://api.github.com/users/cvan","html_url":"https://github.com/cvan","followers_url":"https://api.github.com/users/cvan/followers","following_url":"https://api.github.com/users/cvan/following{/other_user}","gists_url":"https://api.github.com/users/cvan/gists{/gist_id}","starred_url":"https://api.github.com/users/cvan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cvan/subscriptions","organizations_url":"https://api.github.com/users/cvan/orgs","repos_url":"https://api.github.com/users/cvan/repos","events_url":"https://api.github.com/users/cvan/events{/privacy}","received_events_url":"https://api.github.com/users/cvan/received_events","type":"User","site_admin":false},"body":"probably. if you're not on a mac, GTHO.","created_at":"2014-02-11T00:22:15Z","updated_at":"2014-02-11T00:22:15Z","html_url":"https://github.com/cvan/tagz/pull/4#discussion_r9609163","pull_request_url":"https://api.github.com/repos/cvan/tagz/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/cvan/tagz/pulls/comments/9609163"},"html":{"href":"https://github.com/cvan/tagz/pull/4#discussion_r9609163"},"pull_request":{"href":"https://api.github.com/repos/cvan/tagz/pulls/4"}}}}