{"action":"created","comment":{"url":"https://api.github.com/repos/RackHD/on-tools/pulls/comments/88593002","pull_request_review_id":9162804,"id":88593002,"diff_hunk":"@@ -0,0 +1,416 @@\n+#!/usr/bin/env python\n+\n+# Copyright 2015, EMC, Inc.\n+\n+\n+import argparse\n+import datetime\n+import json\n+import os\n+import re\n+import subprocess\n+import sys\n+import tempfile\n+import shutil\n+\n+#pylint: disable=relative-import\n+import config\n+from RepositoryOperator import RepoOperator\n+from manifest import Manifest\n+\n+\n+class UpdateManifest(object):\n+\n+    def __init__(self):\n+        \"\"\"\n+        __repo - the repository url being updated in the manifest\n+        __branch - the branch name associated with __repo\n+        __sliced_branch - the branch name sliced at any forward slashes\n+        __commit - The commit id associated with the __repo and __branch that we want to update\n+        __manifest_repository_url - the repository url the points to the collection of manifest files\n+        __manifest_file - the desired manifest file to update which resides in __manifest_repository_url\n+        __cleanup_directories - the path/name of directories created are appended here for cleanup in task_cleanup\n+        __git_credentials - url, credentials pair for the access to github repos\n+        quiet - used for testing to minimize text written to a terminal\n+        repo_operator - Class instance of RepoOperator\n+        :return: None\n+        \"\"\"\n+        self.__repo = None\n+        self.__branch = None\n+        self.__sliced_branch = None\n+        self.__commit = None\n+        self.__manifest_repository_url = None\n+        self.__manifest_file = None\n+        self.__cleanup_directories = []\n+        self.__git_credentials = None\n+        self.__updated_manifest = None\n+        self.__dryrun = False\n+        self.quiet = False\n+        self.repo_operator = RepoOperator()\n+\n+    #pylint: disable=no-self-use\n+    def parse_args(self, args):\n+        \"\"\"\n+        Take in values from the user.\n+        Repo, branch, and manifest_repo are required. This exits if they are not given.\n+        :return: Parsed args for assignment\n+        \"\"\"\n+        parser = argparse.ArgumentParser()\n+        parser.add_argument('-n', '--dryrun',\n+                            help=\"Do not commit any changes, just print what would be done\",\n+                            action=\"store_true\")\n+        parser.add_argument(\"--repo\",\n+                            help=\"Git url to match for updating the commit-id\",\n+                            action=\"store\")\n+        parser.add_argument(\"--branch\",\n+                            help=\"The target branch for the named repo\",\n+                            action=\"store\")\n+        parser.add_argument(\"--manifest_repo\",\n+                            help=\"The manifest repository URL.\",\n+                            action=\"store\")\n+        parser.add_argument(\"--commit\",\n+                            help=\"OPTIONAL: The commit id to target an exact version\",\n+                            action=\"store\")\n+        parser.add_argument(\"--manifest_file\",\n+                            help=\"The target manifest file to update. Searches through all if left empty.\",\n+                            action=\"store\")\n+        parser.add_argument(\"--git-credential\",\n+                            help=\"Git URL and credentials comma separated\",\n+                            action=\"append\")\n+        parser.add_argument('--updated_manifest',\n+                            help=\"file containing the name of the updated manifest\",\n+                            action=\"store\")\n+        parser = parser.parse_args(args)\n+\n+        return parser\n+\n+\n+    def assign_args(self, args):\n+        \"\"\"\n+        Assign args to member variables and perform checks on branch and commit-id.\n+        :param args: Parsed args from the user\n+        :return:\n+        \"\"\"\n+        if args.repo:\n+            self.__repo = args.repo\n+        else:\n+            print \"\\nMust specify repository url for cloning (--repo <git_url>)\\n\"\n+\n+        if args.branch:\n+            self.__branch = args.branch\n+            if \"/\" in self.__branch:\n+                self.__sliced_branch = self.__branch.split(\"/\")[-1]\n+            else:\n+                self.__sliced_branch = self.__branch\n+        else:\n+            print \"\\nMust specify a branch name (--branch <branch_name>)\\n\"\n+\n+        if args.manifest_repo:\n+            self.__manifest_repository_url = args.manifest_repo\n+        else:\n+            print \"\\n Must specify a full repository url for retrieving <manifest>.json files\\n\"\n+\n+        if args.dryrun:\n+            self.__dryrun = True\n+            self.repo_operator.setup_git_dryrun(self.__dryrun)\n+\n+        if args.commit:\n+            self.__commit = args.commit\n+\n+        if args.manifest_file:\n+            self.__manifest_file = args.manifest_file\n+\n+        if args.git_credential:\n+            self.__git_credentials = args.git_credential\n+            self.repo_operator.setup_gitbit(credentials=self.__git_credentials)\n+\n+        if args.updated_manifest:\n+            self.__updated_manifest = args.updated_manifest\n+\n+    def check_args(self):\n+        \"\"\"\n+        Check the values given for branch and commit-id\n+        \"\"\"\n+        if self.__branch:\n+            try:\n+                self.repo_operator.check_branch(self.__repo, self.__sliced_branch)\n+            except RuntimeError as error:\n+                self.cleanup_and_exit(error, 1)\n+        if self.__commit:\n+            self.__check_commit()\n+\n+\n+    def __check_commit(self):\n+        \"\"\"\n+        Check the format of the commit-id. It must be 40 hex characters.","path":"manifest-build-tools/application/update_manifest.py","position":145,"original_position":145,"commit_id":"9eb1012dabe7a6a5ce1ba67e32748977a7b4243c","original_commit_id":"9eb1012dabe7a6a5ce1ba67e32748977a7b4243c","user":{"login":"panpan0000","id":14049268,"avatar_url":"https://avatars.githubusercontent.com/u/14049268?v=3","gravatar_id":"","url":"https://api.github.com/users/panpan0000","html_url":"https://github.com/panpan0000","followers_url":"https://api.github.com/users/panpan0000/followers","following_url":"https://api.github.com/users/panpan0000/following{/other_user}","gists_url":"https://api.github.com/users/panpan0000/gists{/gist_id}","starred_url":"https://api.github.com/users/panpan0000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/panpan0000/subscriptions","organizations_url":"https://api.github.com/users/panpan0000/orgs","repos_url":"https://api.github.com/users/panpan0000/repos","events_url":"https://api.github.com/users/panpan0000/events{/privacy}","received_events_url":"https://api.github.com/users/panpan0000/received_events","type":"User","site_admin":false},"body":"[non-issue] just an idea. I'm always thinking in theory, 5 or 7 characters of Git Hash is enough...","created_at":"2016-11-18T03:04:00Z","updated_at":"2016-11-18T03:30:30Z","html_url":"https://github.com/RackHD/on-tools/pull/40#discussion_r88593002","pull_request_url":"https://api.github.com/repos/RackHD/on-tools/pulls/40","_links":{"self":{"href":"https://api.github.com/repos/RackHD/on-tools/pulls/comments/88593002"},"html":{"href":"https://github.com/RackHD/on-tools/pull/40#discussion_r88593002"},"pull_request":{"href":"https://api.github.com/repos/RackHD/on-tools/pulls/40"}}},"pull_request":{"url":"https://api.github.com/repos/RackHD/on-tools/pulls/40","id":93535305,"html_url":"https://github.com/RackHD/on-tools/pull/40","diff_url":"https://github.com/RackHD/on-tools/pull/40.diff","patch_url":"https://github.com/RackHD/on-tools/pull/40.patch","issue_url":"https://api.github.com/repos/RackHD/on-tools/issues/40","number":40,"state":"open","locked":false,"title":"update manifest according to repository url, branch and commit","user":{"login":"PengTian0","id":19203416,"avatar_url":"https://avatars.githubusercontent.com/u/19203416?v=3","gravatar_id":"","url":"https://api.github.com/users/PengTian0","html_url":"https://github.com/PengTian0","followers_url":"https://api.github.com/users/PengTian0/followers","following_url":"https://api.github.com/users/PengTian0/following{/other_user}","gists_url":"https://api.github.com/users/PengTian0/gists{/gist_id}","starred_url":"https://api.github.com/users/PengTian0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PengTian0/subscriptions","organizations_url":"https://api.github.com/users/PengTian0/orgs","repos_url":"https://api.github.com/users/PengTian0/repos","events_url":"https://api.github.com/users/PengTian0/events{/privacy}","received_events_url":"https://api.github.com/users/PengTian0/received_events","type":"User","site_admin":false},"body":"**Background:**\r\nManifest records a list of repositories for rackhd.\r\nFor example:\r\n```\r\n        {\r\n            \"branch\": \"master\", \r\n            \"commit-id\": \"38a0d873ffcc847745a0a4b586bc2675a1957ee7\", \r\n            \"repository\": \"https://github.com/RackHD/on-core.git\"\r\n        }\r\n```\r\n Once any of the repositories has PR merged, the commit-id of the repository should be updated.\r\n\r\n**Destination:**\r\nThe script is used to check and  update the commit-id of a repository which has PR merged.\r\n\r\n**Test:**\r\nThe test jenkins job:\r\nhttp://rackhdci.lss.emc.com/job/Maglev-BRI-Test/job/release/job/Update-Manifest/\r\n\r\nThe script is already used for onrack for a long time.\r\n","created_at":"2016-11-14T09:48:29Z","updated_at":"2016-11-18T03:30:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0f5f7fdaef17a22578af7acdd9d5e592c127d906","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/RackHD/on-tools/pulls/40/commits","review_comments_url":"https://api.github.com/repos/RackHD/on-tools/pulls/40/comments","review_comment_url":"https://api.github.com/repos/RackHD/on-tools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/RackHD/on-tools/issues/40/comments","statuses_url":"https://api.github.com/repos/RackHD/on-tools/statuses/9eb1012dabe7a6a5ce1ba67e32748977a7b4243c","head":{"label":"PengTian0:feature/update-manifest","ref":"feature/update-manifest","sha":"9eb1012dabe7a6a5ce1ba67e32748977a7b4243c","user":{"login":"PengTian0","id":19203416,"avatar_url":"https://avatars.githubusercontent.com/u/19203416?v=3","gravatar_id":"","url":"https://api.github.com/users/PengTian0","html_url":"https://github.com/PengTian0","followers_url":"https://api.github.com/users/PengTian0/followers","following_url":"https://api.github.com/users/PengTian0/following{/other_user}","gists_url":"https://api.github.com/users/PengTian0/gists{/gist_id}","starred_url":"https://api.github.com/users/PengTian0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PengTian0/subscriptions","organizations_url":"https://api.github.com/users/PengTian0/orgs","repos_url":"https://api.github.com/users/PengTian0/repos","events_url":"https://api.github.com/users/PengTian0/events{/privacy}","received_events_url":"https://api.github.com/users/PengTian0/received_events","type":"User","site_admin":false},"repo":{"id":58620365,"name":"on-tools","full_name":"PengTian0/on-tools","owner":{"login":"PengTian0","id":19203416,"avatar_url":"https://avatars.githubusercontent.com/u/19203416?v=3","gravatar_id":"","url":"https://api.github.com/users/PengTian0","html_url":"https://github.com/PengTian0","followers_url":"https://api.github.com/users/PengTian0/followers","following_url":"https://api.github.com/users/PengTian0/following{/other_user}","gists_url":"https://api.github.com/users/PengTian0/gists{/gist_id}","starred_url":"https://api.github.com/users/PengTian0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PengTian0/subscriptions","organizations_url":"https://api.github.com/users/PengTian0/orgs","repos_url":"https://api.github.com/users/PengTian0/repos","events_url":"https://api.github.com/users/PengTian0/events{/privacy}","received_events_url":"https://api.github.com/users/PengTian0/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/PengTian0/on-tools","description":null,"fork":true,"url":"https://api.github.com/repos/PengTian0/on-tools","forks_url":"https://api.github.com/repos/PengTian0/on-tools/forks","keys_url":"https://api.github.com/repos/PengTian0/on-tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PengTian0/on-tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PengTian0/on-tools/teams","hooks_url":"https://api.github.com/repos/PengTian0/on-tools/hooks","issue_events_url":"https://api.github.com/repos/PengTian0/on-tools/issues/events{/number}","events_url":"https://api.github.com/repos/PengTian0/on-tools/events","assignees_url":"https://api.github.com/repos/PengTian0/on-tools/assignees{/user}","branches_url":"https://api.github.com/repos/PengTian0/on-tools/branches{/branch}","tags_url":"https://api.github.com/repos/PengTian0/on-tools/tags","blobs_url":"https://api.github.com/repos/PengTian0/on-tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PengTian0/on-tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PengTian0/on-tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/PengTian0/on-tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PengTian0/on-tools/statuses/{sha}","languages_url":"https://api.github.com/repos/PengTian0/on-tools/languages","stargazers_url":"https://api.github.com/repos/PengTian0/on-tools/stargazers","contributors_url":"https://api.github.com/repos/PengTian0/on-tools/contributors","subscribers_url":"https://api.github.com/repos/PengTian0/on-tools/subscribers","subscription_url":"https://api.github.com/repos/PengTian0/on-tools/subscription","commits_url":"https://api.github.com/repos/PengTian0/on-tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/PengTian0/on-tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/PengTian0/on-tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/PengTian0/on-tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/PengTian0/on-tools/contents/{+path}","compare_url":"https://api.github.com/repos/PengTian0/on-tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PengTian0/on-tools/merges","archive_url":"https://api.github.com/repos/PengTian0/on-tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PengTian0/on-tools/downloads","issues_url":"https://api.github.com/repos/PengTian0/on-tools/issues{/number}","pulls_url":"https://api.github.com/repos/PengTian0/on-tools/pulls{/number}","milestones_url":"https://api.github.com/repos/PengTian0/on-tools/milestones{/number}","notifications_url":"https://api.github.com/repos/PengTian0/on-tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PengTian0/on-tools/labels{/name}","releases_url":"https://api.github.com/repos/PengTian0/on-tools/releases{/id}","deployments_url":"https://api.github.com/repos/PengTian0/on-tools/deployments","created_at":"2016-05-12T07:54:29Z","updated_at":"2016-11-14T03:55:26Z","pushed_at":"2016-11-18T02:57:53Z","git_url":"git://github.com/PengTian0/on-tools.git","ssh_url":"git@github.com:PengTian0/on-tools.git","clone_url":"https://github.com/PengTian0/on-tools.git","svn_url":"https://github.com/PengTian0/on-tools","homepage":null,"size":298,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"RackHD:master","ref":"master","sha":"8f2f454091b24b20b124baaacf7d4a7361544388","user":{"login":"RackHD","id":13982662,"avatar_url":"https://avatars.githubusercontent.com/u/13982662?v=3","gravatar_id":"","url":"https://api.github.com/users/RackHD","html_url":"https://github.com/RackHD","followers_url":"https://api.github.com/users/RackHD/followers","following_url":"https://api.github.com/users/RackHD/following{/other_user}","gists_url":"https://api.github.com/users/RackHD/gists{/gist_id}","starred_url":"https://api.github.com/users/RackHD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RackHD/subscriptions","organizations_url":"https://api.github.com/users/RackHD/orgs","repos_url":"https://api.github.com/users/RackHD/repos","events_url":"https://api.github.com/users/RackHD/events{/privacy}","received_events_url":"https://api.github.com/users/RackHD/received_events","type":"Organization","site_admin":false},"repo":{"id":41690106,"name":"on-tools","full_name":"RackHD/on-tools","owner":{"login":"RackHD","id":13982662,"avatar_url":"https://avatars.githubusercontent.com/u/13982662?v=3","gravatar_id":"","url":"https://api.github.com/users/RackHD","html_url":"https://github.com/RackHD","followers_url":"https://api.github.com/users/RackHD/followers","following_url":"https://api.github.com/users/RackHD/following{/other_user}","gists_url":"https://api.github.com/users/RackHD/gists{/gist_id}","starred_url":"https://api.github.com/users/RackHD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RackHD/subscriptions","organizations_url":"https://api.github.com/users/RackHD/orgs","repos_url":"https://api.github.com/users/RackHD/repos","events_url":"https://api.github.com/users/RackHD/events{/privacy}","received_events_url":"https://api.github.com/users/RackHD/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/RackHD/on-tools","description":null,"fork":false,"url":"https://api.github.com/repos/RackHD/on-tools","forks_url":"https://api.github.com/repos/RackHD/on-tools/forks","keys_url":"https://api.github.com/repos/RackHD/on-tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RackHD/on-tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RackHD/on-tools/teams","hooks_url":"https://api.github.com/repos/RackHD/on-tools/hooks","issue_events_url":"https://api.github.com/repos/RackHD/on-tools/issues/events{/number}","events_url":"https://api.github.com/repos/RackHD/on-tools/events","assignees_url":"https://api.github.com/repos/RackHD/on-tools/assignees{/user}","branches_url":"https://api.github.com/repos/RackHD/on-tools/branches{/branch}","tags_url":"https://api.github.com/repos/RackHD/on-tools/tags","blobs_url":"https://api.github.com/repos/RackHD/on-tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RackHD/on-tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RackHD/on-tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/RackHD/on-tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RackHD/on-tools/statuses/{sha}","languages_url":"https://api.github.com/repos/RackHD/on-tools/languages","stargazers_url":"https://api.github.com/repos/RackHD/on-tools/stargazers","contributors_url":"https://api.github.com/repos/RackHD/on-tools/contributors","subscribers_url":"https://api.github.com/repos/RackHD/on-tools/subscribers","subscription_url":"https://api.github.com/repos/RackHD/on-tools/subscription","commits_url":"https://api.github.com/repos/RackHD/on-tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/RackHD/on-tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/RackHD/on-tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/RackHD/on-tools/issues/comments{/number}","contents_url":"https://api.github.com/repos/RackHD/on-tools/contents/{+path}","compare_url":"https://api.github.com/repos/RackHD/on-tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RackHD/on-tools/merges","archive_url":"https://api.github.com/repos/RackHD/on-tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RackHD/on-tools/downloads","issues_url":"https://api.github.com/repos/RackHD/on-tools/issues{/number}","pulls_url":"https://api.github.com/repos/RackHD/on-tools/pulls{/number}","milestones_url":"https://api.github.com/repos/RackHD/on-tools/milestones{/number}","notifications_url":"https://api.github.com/repos/RackHD/on-tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RackHD/on-tools/labels{/name}","releases_url":"https://api.github.com/repos/RackHD/on-tools/releases{/id}","deployments_url":"https://api.github.com/repos/RackHD/on-tools/deployments","created_at":"2015-08-31T17:29:38Z","updated_at":"2016-11-11T07:17:06Z","pushed_at":"2016-11-18T02:57:53Z","git_url":"git://github.com/RackHD/on-tools.git","ssh_url":"git@github.com:RackHD/on-tools.git","clone_url":"https://github.com/RackHD/on-tools.git","svn_url":"https://github.com/RackHD/on-tools","homepage":null,"size":250,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":6,"forks":24,"open_issues":6,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/RackHD/on-tools/pulls/40"},"html":{"href":"https://github.com/RackHD/on-tools/pull/40"},"issue":{"href":"https://api.github.com/repos/RackHD/on-tools/issues/40"},"comments":{"href":"https://api.github.com/repos/RackHD/on-tools/issues/40/comments"},"review_comments":{"href":"https://api.github.com/repos/RackHD/on-tools/pulls/40/comments"},"review_comment":{"href":"https://api.github.com/repos/RackHD/on-tools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/RackHD/on-tools/pulls/40/commits"},"statuses":{"href":"https://api.github.com/repos/RackHD/on-tools/statuses/9eb1012dabe7a6a5ce1ba67e32748977a7b4243c"}}}}
{"actor":{"display_login":"panpan0000"}}