{"action":"created","comment":{"url":"https://api.github.com/repos/puppetlabs/pdk/pulls/comments/194128082","pull_request_review_id":127249224,"id":194128082,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NDEyODA4Mg==","diff_hunk":"@@ -68,19 +68,21 @@ def self.invoke(opts = {})\n           metadata.write!(File.join(temp_target_dir, 'metadata.json'))\n         end\n \n-        if template_url == PDK::Util.puppetlabs_template_url\n-          # If the user specifies our template via the command line, remove the\n-          # saved template-url answer.\n+        # Only update the answers files after metadata has been written.\n+        if template_uri == PDK::Util.default_template_uri\n+          # If the user specifies our default template url via the command\n+          # line, remove the saved template-url answer so that the template_uri\n+          # resolution can find new default URLs in the future.\n           PDK.answers.update!('template-url' => nil) if opts.key?(:'template-url')\n         else\n-          # Save the template-url answer if the module was generated using\n-          # a template other than ours.\n-          PDK.answers.update!('template-url' => template_url)\n+          # Save the template-url + template-ref answers if the module was","path":"lib/pdk/generate/module.rb","position":29,"original_position":29,"commit_id":"cee46340712d6df154a35157e60ebbb9dbc2459b","original_commit_id":"cee46340712d6df154a35157e60ebbb9dbc2459b","user":{"login":"hunner","id":91972,"node_id":"MDQ6VXNlcjkxOTcy","avatar_url":"https://avatars0.githubusercontent.com/u/91972?v=4","gravatar_id":"","url":"https://api.github.com/users/hunner","html_url":"https://github.com/hunner","followers_url":"https://api.github.com/users/hunner/followers","following_url":"https://api.github.com/users/hunner/following{/other_user}","gists_url":"https://api.github.com/users/hunner/gists{/gist_id}","starred_url":"https://api.github.com/users/hunner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hunner/subscriptions","organizations_url":"https://api.github.com/users/hunner/orgs","repos_url":"https://api.github.com/users/hunner/repos","events_url":"https://api.github.com/users/hunner/events{/privacy}","received_events_url":"https://api.github.com/users/hunner/received_events","type":"User","site_admin":false},"body":"That's by design, so I'll update the comment. \r\n\r\nTo expound on that, the git reference is encoded into the `template-url` via the fragment. The only time `template-ref` is externalized as part of pdk is when it's added to the metadata.json to indicate the last template ref that was used by `pdk update`.","created_at":"2018-06-08T17:28:22Z","updated_at":"2018-06-08T17:28:22Z","html_url":"https://github.com/puppetlabs/pdk/pull/434#discussion_r194128082","pull_request_url":"https://api.github.com/repos/puppetlabs/pdk/pulls/434","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/pdk/pulls/comments/194128082"},"html":{"href":"https://github.com/puppetlabs/pdk/pull/434#discussion_r194128082"},"pull_request":{"href":"https://api.github.com/repos/puppetlabs/pdk/pulls/434"}},"in_reply_to_id":193938092},"pull_request":{"url":"https://api.github.com/repos/puppetlabs/pdk/pulls/434","id":170655802,"node_id":"MDExOlB1bGxSZXF1ZXN0MTcwNjU1ODAy","html_url":"https://github.com/puppetlabs/pdk/pull/434","diff_url":"https://github.com/puppetlabs/pdk/pull/434.diff","patch_url":"https://github.com/puppetlabs/pdk/pull/434.patch","issue_url":"https://api.github.com/repos/puppetlabs/pdk/issues/434","number":434,"state":"open","locked":false,"title":"(PDK-718) Add --template-ref argument for upstream template repo tags","user":{"login":"hunner","id":91972,"node_id":"MDQ6VXNlcjkxOTcy","avatar_url":"https://avatars0.githubusercontent.com/u/91972?v=4","gravatar_id":"","url":"https://api.github.com/users/hunner","html_url":"https://github.com/hunner","followers_url":"https://api.github.com/users/hunner/followers","following_url":"https://api.github.com/users/hunner/following{/other_user}","gists_url":"https://api.github.com/users/hunner/gists{/gist_id}","starred_url":"https://api.github.com/users/hunner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hunner/subscriptions","organizations_url":"https://api.github.com/users/hunner/orgs","repos_url":"https://api.github.com/users/hunner/repos","events_url":"https://api.github.com/users/hunner/events{/privacy}","received_events_url":"https://api.github.com/users/hunner/received_events","type":"User","site_admin":false},"body":"I rolled the url/refs together internally into a single \"uri\" that should be considered the template target and broken apart with the URI & decode methods when needed separately.\r\n\r\n- The decision code for obtaining the uri/ref has been centralized into the `PDK::Util` functions as discussed on the PR comments on github.  \r\n- The template-ref value in the metadata is for pdk update reference, not for template targetting.  \r\n- The default ref is to be used when no fragment is available in the URI.  \r\n- The `PDK::Util.template_uri()` takes options hash for the opts.fetch in case users pass --arguments, but is a class method. I don't really like this, but it's probably needed to fulfill the requirements discussed in the PR.  \r\n- The `file:///...` urls are treated as remote paths, but absolute paths such as `c:/...` or `/...` are treated as local paths and use directly.  This behavior was pre-existing.  \r\n- The work tree for the templates directory is only reset newly-cloned directorys, and should not be touched in the above-mentioned local-path directories.  \r\n- Handling file paths with #'s in the name is overly complex due to the way URI encoding and URI fragments work. I just error in the case of #'s \r\n- The Addressable::URI library is the most-compatible URI handler, so I used that.  \r\n- SCP-like urls of user@host:/path are not URI RFC-compatible, so I helpfully parse them into URIs and print a warning. (The ambiguous case is `user@host:<0-65535>/path` in which I interpret this as a URI instead of an SCP url) \r\n- I removed the --template-url --template-ref arguments from most of the `pdk new *` generators as they are not used to specify or change templates and actually create edge cases by being used to do so. The arguments should only be specified during a pdk convert or a `pdk new module` \r\n- Most of the spec fixes only have to do with shuffling a few stubs around and lining up string/addressable::uri expectations.  \r\n- One awkward thing I noticed is that the spec_helper.rb on line 33 loads the answers by requiring pdk/cli and it happens before any stubs are placed so polluted answers.json on my machine is picked up instead of stubs. This should be documented probably as I lost a few hours to it.  \r\n- Windows paths most start with either a `file:///<drive>:/...` scheme or `/<drive>:/` leading-slash to be URI-compatible. I represent paths that lack the `file://` scheme as `/<drive>:/` internally and strip the leading / when used for commands or serialization in metadata.json.\r\n","created_at":"2018-02-22T04:43:22Z","updated_at":"2018-06-08T17:28:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6711b5be57184cb6b3972fb31be2711220cb828a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":526434205,"node_id":"MDU6TGFiZWw1MjY0MzQyMDU=","url":"https://api.github.com/repos/puppetlabs/pdk/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"milestone":null,"commits_url":"https://api.github.com/repos/puppetlabs/pdk/pulls/434/commits","review_comments_url":"https://api.github.com/repos/puppetlabs/pdk/pulls/434/comments","review_comment_url":"https://api.github.com/repos/puppetlabs/pdk/pulls/comments{/number}","comments_url":"https://api.github.com/repos/puppetlabs/pdk/issues/434/comments","statuses_url":"https://api.github.com/repos/puppetlabs/pdk/statuses/cee46340712d6df154a35157e60ebbb9dbc2459b","head":{"label":"hunner:add_template_ref","ref":"add_template_ref","sha":"cee46340712d6df154a35157e60ebbb9dbc2459b","user":{"login":"hunner","id":91972,"node_id":"MDQ6VXNlcjkxOTcy","avatar_url":"https://avatars0.githubusercontent.com/u/91972?v=4","gravatar_id":"","url":"https://api.github.com/users/hunner","html_url":"https://github.com/hunner","followers_url":"https://api.github.com/users/hunner/followers","following_url":"https://api.github.com/users/hunner/following{/other_user}","gists_url":"https://api.github.com/users/hunner/gists{/gist_id}","starred_url":"https://api.github.com/users/hunner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hunner/subscriptions","organizations_url":"https://api.github.com/users/hunner/orgs","repos_url":"https://api.github.com/users/hunner/repos","events_url":"https://api.github.com/users/hunner/events{/privacy}","received_events_url":"https://api.github.com/users/hunner/received_events","type":"User","site_admin":false},"repo":{"id":122411056,"node_id":"MDEwOlJlcG9zaXRvcnkxMjI0MTEwNTY=","name":"pdk","full_name":"hunner/pdk","owner":{"login":"hunner","id":91972,"node_id":"MDQ6VXNlcjkxOTcy","avatar_url":"https://avatars0.githubusercontent.com/u/91972?v=4","gravatar_id":"","url":"https://api.github.com/users/hunner","html_url":"https://github.com/hunner","followers_url":"https://api.github.com/users/hunner/followers","following_url":"https://api.github.com/users/hunner/following{/other_user}","gists_url":"https://api.github.com/users/hunner/gists{/gist_id}","starred_url":"https://api.github.com/users/hunner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hunner/subscriptions","organizations_url":"https://api.github.com/users/hunner/orgs","repos_url":"https://api.github.com/users/hunner/repos","events_url":"https://api.github.com/users/hunner/events{/privacy}","received_events_url":"https://api.github.com/users/hunner/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hunner/pdk","description":"The shortest path to better modules: Puppet Development Kit; Download:","fork":true,"url":"https://api.github.com/repos/hunner/pdk","forks_url":"https://api.github.com/repos/hunner/pdk/forks","keys_url":"https://api.github.com/repos/hunner/pdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hunner/pdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hunner/pdk/teams","hooks_url":"https://api.github.com/repos/hunner/pdk/hooks","issue_events_url":"https://api.github.com/repos/hunner/pdk/issues/events{/number}","events_url":"https://api.github.com/repos/hunner/pdk/events","assignees_url":"https://api.github.com/repos/hunner/pdk/assignees{/user}","branches_url":"https://api.github.com/repos/hunner/pdk/branches{/branch}","tags_url":"https://api.github.com/repos/hunner/pdk/tags","blobs_url":"https://api.github.com/repos/hunner/pdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hunner/pdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hunner/pdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/hunner/pdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hunner/pdk/statuses/{sha}","languages_url":"https://api.github.com/repos/hunner/pdk/languages","stargazers_url":"https://api.github.com/repos/hunner/pdk/stargazers","contributors_url":"https://api.github.com/repos/hunner/pdk/contributors","subscribers_url":"https://api.github.com/repos/hunner/pdk/subscribers","subscription_url":"https://api.github.com/repos/hunner/pdk/subscription","commits_url":"https://api.github.com/repos/hunner/pdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/hunner/pdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/hunner/pdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/hunner/pdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/hunner/pdk/contents/{+path}","compare_url":"https://api.github.com/repos/hunner/pdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hunner/pdk/merges","archive_url":"https://api.github.com/repos/hunner/pdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hunner/pdk/downloads","issues_url":"https://api.github.com/repos/hunner/pdk/issues{/number}","pulls_url":"https://api.github.com/repos/hunner/pdk/pulls{/number}","milestones_url":"https://api.github.com/repos/hunner/pdk/milestones{/number}","notifications_url":"https://api.github.com/repos/hunner/pdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hunner/pdk/labels{/name}","releases_url":"https://api.github.com/repos/hunner/pdk/releases{/id}","deployments_url":"https://api.github.com/repos/hunner/pdk/deployments","created_at":"2018-02-22T00:25:11Z","updated_at":"2018-02-22T00:25:13Z","pushed_at":"2018-05-22T00:45:32Z","git_url":"git://github.com/hunner/pdk.git","ssh_url":"git@github.com:hunner/pdk.git","clone_url":"https://github.com/hunner/pdk.git","svn_url":"https://github.com/hunner/pdk","homepage":"https://puppet.com/download-puppet-development-kit","size":1336,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"puppetlabs:master","ref":"master","sha":"1c719d99adaf5f887d56331812e028cf0fa3be92","user":{"login":"puppetlabs","id":234268,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzNDI2OA==","avatar_url":"https://avatars0.githubusercontent.com/u/234268?v=4","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":80118170,"node_id":"MDEwOlJlcG9zaXRvcnk4MDExODE3MA==","name":"pdk","full_name":"puppetlabs/pdk","owner":{"login":"puppetlabs","id":234268,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIzNDI2OA==","avatar_url":"https://avatars0.githubusercontent.com/u/234268?v=4","gravatar_id":"","url":"https://api.github.com/users/puppetlabs","html_url":"https://github.com/puppetlabs","followers_url":"https://api.github.com/users/puppetlabs/followers","following_url":"https://api.github.com/users/puppetlabs/following{/other_user}","gists_url":"https://api.github.com/users/puppetlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/puppetlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puppetlabs/subscriptions","organizations_url":"https://api.github.com/users/puppetlabs/orgs","repos_url":"https://api.github.com/users/puppetlabs/repos","events_url":"https://api.github.com/users/puppetlabs/events{/privacy}","received_events_url":"https://api.github.com/users/puppetlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/puppetlabs/pdk","description":"The shortest path to better modules: Puppet Development Kit; Download:","fork":false,"url":"https://api.github.com/repos/puppetlabs/pdk","forks_url":"https://api.github.com/repos/puppetlabs/pdk/forks","keys_url":"https://api.github.com/repos/puppetlabs/pdk/keys{/key_id}","collaborators_url":"https://api.github.com/repos/puppetlabs/pdk/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/puppetlabs/pdk/teams","hooks_url":"https://api.github.com/repos/puppetlabs/pdk/hooks","issue_events_url":"https://api.github.com/repos/puppetlabs/pdk/issues/events{/number}","events_url":"https://api.github.com/repos/puppetlabs/pdk/events","assignees_url":"https://api.github.com/repos/puppetlabs/pdk/assignees{/user}","branches_url":"https://api.github.com/repos/puppetlabs/pdk/branches{/branch}","tags_url":"https://api.github.com/repos/puppetlabs/pdk/tags","blobs_url":"https://api.github.com/repos/puppetlabs/pdk/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/puppetlabs/pdk/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/puppetlabs/pdk/git/refs{/sha}","trees_url":"https://api.github.com/repos/puppetlabs/pdk/git/trees{/sha}","statuses_url":"https://api.github.com/repos/puppetlabs/pdk/statuses/{sha}","languages_url":"https://api.github.com/repos/puppetlabs/pdk/languages","stargazers_url":"https://api.github.com/repos/puppetlabs/pdk/stargazers","contributors_url":"https://api.github.com/repos/puppetlabs/pdk/contributors","subscribers_url":"https://api.github.com/repos/puppetlabs/pdk/subscribers","subscription_url":"https://api.github.com/repos/puppetlabs/pdk/subscription","commits_url":"https://api.github.com/repos/puppetlabs/pdk/commits{/sha}","git_commits_url":"https://api.github.com/repos/puppetlabs/pdk/git/commits{/sha}","comments_url":"https://api.github.com/repos/puppetlabs/pdk/comments{/number}","issue_comment_url":"https://api.github.com/repos/puppetlabs/pdk/issues/comments{/number}","contents_url":"https://api.github.com/repos/puppetlabs/pdk/contents/{+path}","compare_url":"https://api.github.com/repos/puppetlabs/pdk/compare/{base}...{head}","merges_url":"https://api.github.com/repos/puppetlabs/pdk/merges","archive_url":"https://api.github.com/repos/puppetlabs/pdk/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/puppetlabs/pdk/downloads","issues_url":"https://api.github.com/repos/puppetlabs/pdk/issues{/number}","pulls_url":"https://api.github.com/repos/puppetlabs/pdk/pulls{/number}","milestones_url":"https://api.github.com/repos/puppetlabs/pdk/milestones{/number}","notifications_url":"https://api.github.com/repos/puppetlabs/pdk/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/puppetlabs/pdk/labels{/name}","releases_url":"https://api.github.com/repos/puppetlabs/pdk/releases{/id}","deployments_url":"https://api.github.com/repos/puppetlabs/pdk/deployments","created_at":"2017-01-26T13:46:25Z","updated_at":"2018-06-01T17:25:06Z","pushed_at":"2018-06-07T07:05:50Z","git_url":"git://github.com/puppetlabs/pdk.git","ssh_url":"git@github.com:puppetlabs/pdk.git","clone_url":"https://github.com/puppetlabs/pdk.git","svn_url":"https://github.com/puppetlabs/pdk","homepage":"https://puppet.com/download-puppet-development-kit","size":1298,"stargazers_count":126,"watchers_count":126,"language":"Ruby","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":36,"mirror_url":null,"archived":false,"open_issues_count":40,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":36,"open_issues":40,"watchers":126,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/puppetlabs/pdk/pulls/434"},"html":{"href":"https://github.com/puppetlabs/pdk/pull/434"},"issue":{"href":"https://api.github.com/repos/puppetlabs/pdk/issues/434"},"comments":{"href":"https://api.github.com/repos/puppetlabs/pdk/issues/434/comments"},"review_comments":{"href":"https://api.github.com/repos/puppetlabs/pdk/pulls/434/comments"},"review_comment":{"href":"https://api.github.com/repos/puppetlabs/pdk/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/puppetlabs/pdk/pulls/434/commits"},"statuses":{"href":"https://api.github.com/repos/puppetlabs/pdk/statuses/cee46340712d6df154a35157e60ebbb9dbc2459b"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"hunner"}}