{"action":"created","comment":{"url":"https://api.github.com/repos/u-root/u-root/pulls/comments/218624077","pull_request_review_id":156605237,"id":218624077,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxODYyNDA3Nw==","diff_hunk":"@@ -20,23 +20,57 @@ import (\n \t\"path/filepath\"\n )\n \n+var (\n+\tupdate = flag.Bool(\"u\", false, \"move only when the SOURCE file is newer than the destination file or when the destination file is missing\")\n+)\n+\n func usage() {\n-\tfmt.Fprintf(os.Stderr, \"usage: %s source target\\n\", os.Args[0])\n-\tfmt.Fprintf(os.Stderr, \"       %s source ... directory\\n\", os.Args[0])\n+\tfmt.Fprintf(os.Stderr, \"Usage: %s [ARGS] source target\\n\", os.Args[0])\n+\tfmt.Fprintf(os.Stderr, \"       %s [ARGS] source ... directory\\n\", os.Args[0])\n+\tflag.PrintDefaults()\n \tos.Exit(1)\n }\n \n+func moveFile(source string, dest string) error {\n+\tif *update {\n+\t\tvar err error\n+\t\tvar sourceModTime, destModTime os.FileInfo\n+\n+\t\tsourceModTime, err = os.Lstat(source)\n+\t\tif err != nil {\n+\t\t\treturn err\n+\t\t}\n+\t\tvar sourceDate = sourceModTime.ModTime()\n+\n+\t\t// Check if the destination already exists and was touched later than the source\n+\t\tdestModTime, err = os.Lstat(dest)\n+\t\tif err == nil {","path":"cmds/mv/mv.go","position":46,"original_position":46,"commit_id":"6cb5e5badd8a742c9dff8a6dd1a07a024c81181b","original_commit_id":"6cb5e5badd8a742c9dff8a6dd1a07a024c81181b","user":{"login":"JohnAZoidberg","id":5307138,"node_id":"MDQ6VXNlcjUzMDcxMzg=","avatar_url":"https://avatars0.githubusercontent.com/u/5307138?v=4","gravatar_id":"","url":"https://api.github.com/users/JohnAZoidberg","html_url":"https://github.com/JohnAZoidberg","followers_url":"https://api.github.com/users/JohnAZoidberg/followers","following_url":"https://api.github.com/users/JohnAZoidberg/following{/other_user}","gists_url":"https://api.github.com/users/JohnAZoidberg/gists{/gist_id}","starred_url":"https://api.github.com/users/JohnAZoidberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohnAZoidberg/subscriptions","organizations_url":"https://api.github.com/users/JohnAZoidberg/orgs","repos_url":"https://api.github.com/users/JohnAZoidberg/repos","events_url":"https://api.github.com/users/JohnAZoidberg/events{/privacy}","received_events_url":"https://api.github.com/users/JohnAZoidberg/received_events","type":"User","site_admin":false},"body":"Alright. So it's fine to use the same variable (e.g. err) for multiple purposes one after another?\r\nThat's why I introduced the additional scope in TestMvUpdate - so the variable isn't reused but we have the same name in different scopes.","created_at":"2018-09-18T23:15:07Z","updated_at":"2018-09-18T23:15:07Z","html_url":"https://github.com/u-root/u-root/pull/945#discussion_r218624077","pull_request_url":"https://api.github.com/repos/u-root/u-root/pulls/945","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/u-root/u-root/pulls/comments/218624077"},"html":{"href":"https://github.com/u-root/u-root/pull/945#discussion_r218624077"},"pull_request":{"href":"https://api.github.com/repos/u-root/u-root/pulls/945"}},"in_reply_to_id":218393892},"pull_request":{"url":"https://api.github.com/repos/u-root/u-root/pulls/945","id":215852026,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE1ODUyMDI2","html_url":"https://github.com/u-root/u-root/pull/945","diff_url":"https://github.com/u-root/u-root/pull/945.diff","patch_url":"https://github.com/u-root/u-root/pull/945.patch","issue_url":"https://api.github.com/repos/u-root/u-root/issues/945","number":945,"state":"open","locked":false,"title":"mv: Add update switch","user":{"login":"JohnAZoidberg","id":5307138,"node_id":"MDQ6VXNlcjUzMDcxMzg=","avatar_url":"https://avatars0.githubusercontent.com/u/5307138?v=4","gravatar_id":"","url":"https://api.github.com/users/JohnAZoidberg","html_url":"https://github.com/JohnAZoidberg","followers_url":"https://api.github.com/users/JohnAZoidberg/followers","following_url":"https://api.github.com/users/JohnAZoidberg/following{/other_user}","gists_url":"https://api.github.com/users/JohnAZoidberg/gists{/gist_id}","starred_url":"https://api.github.com/users/JohnAZoidberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohnAZoidberg/subscriptions","organizations_url":"https://api.github.com/users/JohnAZoidberg/orgs","repos_url":"https://api.github.com/users/JohnAZoidberg/repos","events_url":"https://api.github.com/users/JohnAZoidberg/events{/privacy}","received_events_url":"https://api.github.com/users/JohnAZoidberg/received_events","type":"User","site_admin":false},"body":"This pull request adds the `-u` switch which only moves files if the source is newer than the destination.\r\n\r\nThe existing tests that were there are pretty useless, they only check that there is no error. Those could be improved as well. The best case would be some declarative tests that describe how the file system and files look like before and after a command. That would be useful for other commands as well - is there something like this?\r\n\r\nI'm welcome to criticism :)\r\n\r\n`-n` is very similar, I'll do that when I have a few minutes time.","created_at":"2018-09-16T23:34:15Z","updated_at":"2018-09-18T23:15:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ac32060ec5346a61a60962f8cf1205b58848621a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/u-root/u-root/pulls/945/commits","review_comments_url":"https://api.github.com/repos/u-root/u-root/pulls/945/comments","review_comment_url":"https://api.github.com/repos/u-root/u-root/pulls/comments{/number}","comments_url":"https://api.github.com/repos/u-root/u-root/issues/945/comments","statuses_url":"https://api.github.com/repos/u-root/u-root/statuses/6cb5e5badd8a742c9dff8a6dd1a07a024c81181b","head":{"label":"JohnAZoidberg:mv-update","ref":"mv-update","sha":"6cb5e5badd8a742c9dff8a6dd1a07a024c81181b","user":{"login":"JohnAZoidberg","id":5307138,"node_id":"MDQ6VXNlcjUzMDcxMzg=","avatar_url":"https://avatars0.githubusercontent.com/u/5307138?v=4","gravatar_id":"","url":"https://api.github.com/users/JohnAZoidberg","html_url":"https://github.com/JohnAZoidberg","followers_url":"https://api.github.com/users/JohnAZoidberg/followers","following_url":"https://api.github.com/users/JohnAZoidberg/following{/other_user}","gists_url":"https://api.github.com/users/JohnAZoidberg/gists{/gist_id}","starred_url":"https://api.github.com/users/JohnAZoidberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohnAZoidberg/subscriptions","organizations_url":"https://api.github.com/users/JohnAZoidberg/orgs","repos_url":"https://api.github.com/users/JohnAZoidberg/repos","events_url":"https://api.github.com/users/JohnAZoidberg/events{/privacy}","received_events_url":"https://api.github.com/users/JohnAZoidberg/received_events","type":"User","site_admin":false},"repo":{"id":149043961,"node_id":"MDEwOlJlcG9zaXRvcnkxNDkwNDM5NjE=","name":"u-root","full_name":"JohnAZoidberg/u-root","private":false,"owner":{"login":"JohnAZoidberg","id":5307138,"node_id":"MDQ6VXNlcjUzMDcxMzg=","avatar_url":"https://avatars0.githubusercontent.com/u/5307138?v=4","gravatar_id":"","url":"https://api.github.com/users/JohnAZoidberg","html_url":"https://github.com/JohnAZoidberg","followers_url":"https://api.github.com/users/JohnAZoidberg/followers","following_url":"https://api.github.com/users/JohnAZoidberg/following{/other_user}","gists_url":"https://api.github.com/users/JohnAZoidberg/gists{/gist_id}","starred_url":"https://api.github.com/users/JohnAZoidberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JohnAZoidberg/subscriptions","organizations_url":"https://api.github.com/users/JohnAZoidberg/orgs","repos_url":"https://api.github.com/users/JohnAZoidberg/repos","events_url":"https://api.github.com/users/JohnAZoidberg/events{/privacy}","received_events_url":"https://api.github.com/users/JohnAZoidberg/received_events","type":"User","site_admin":false},"html_url":"https://github.com/JohnAZoidberg/u-root","description":"A fully Go userland! u-root can create a root file system (initramfs) containing a busybox-like set of tools written in Go.","fork":true,"url":"https://api.github.com/repos/JohnAZoidberg/u-root","forks_url":"https://api.github.com/repos/JohnAZoidberg/u-root/forks","keys_url":"https://api.github.com/repos/JohnAZoidberg/u-root/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JohnAZoidberg/u-root/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JohnAZoidberg/u-root/teams","hooks_url":"https://api.github.com/repos/JohnAZoidberg/u-root/hooks","issue_events_url":"https://api.github.com/repos/JohnAZoidberg/u-root/issues/events{/number}","events_url":"https://api.github.com/repos/JohnAZoidberg/u-root/events","assignees_url":"https://api.github.com/repos/JohnAZoidberg/u-root/assignees{/user}","branches_url":"https://api.github.com/repos/JohnAZoidberg/u-root/branches{/branch}","tags_url":"https://api.github.com/repos/JohnAZoidberg/u-root/tags","blobs_url":"https://api.github.com/repos/JohnAZoidberg/u-root/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JohnAZoidberg/u-root/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JohnAZoidberg/u-root/git/refs{/sha}","trees_url":"https://api.github.com/repos/JohnAZoidberg/u-root/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JohnAZoidberg/u-root/statuses/{sha}","languages_url":"https://api.github.com/repos/JohnAZoidberg/u-root/languages","stargazers_url":"https://api.github.com/repos/JohnAZoidberg/u-root/stargazers","contributors_url":"https://api.github.com/repos/JohnAZoidberg/u-root/contributors","subscribers_url":"https://api.github.com/repos/JohnAZoidberg/u-root/subscribers","subscription_url":"https://api.github.com/repos/JohnAZoidberg/u-root/subscription","commits_url":"https://api.github.com/repos/JohnAZoidberg/u-root/commits{/sha}","git_commits_url":"https://api.github.com/repos/JohnAZoidberg/u-root/git/commits{/sha}","comments_url":"https://api.github.com/repos/JohnAZoidberg/u-root/comments{/number}","issue_comment_url":"https://api.github.com/repos/JohnAZoidberg/u-root/issues/comments{/number}","contents_url":"https://api.github.com/repos/JohnAZoidberg/u-root/contents/{+path}","compare_url":"https://api.github.com/repos/JohnAZoidberg/u-root/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JohnAZoidberg/u-root/merges","archive_url":"https://api.github.com/repos/JohnAZoidberg/u-root/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JohnAZoidberg/u-root/downloads","issues_url":"https://api.github.com/repos/JohnAZoidberg/u-root/issues{/number}","pulls_url":"https://api.github.com/repos/JohnAZoidberg/u-root/pulls{/number}","milestones_url":"https://api.github.com/repos/JohnAZoidberg/u-root/milestones{/number}","notifications_url":"https://api.github.com/repos/JohnAZoidberg/u-root/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JohnAZoidberg/u-root/labels{/name}","releases_url":"https://api.github.com/repos/JohnAZoidberg/u-root/releases{/id}","deployments_url":"https://api.github.com/repos/JohnAZoidberg/u-root/deployments","created_at":"2018-09-16T23:17:15Z","updated_at":"2018-09-16T23:17:31Z","pushed_at":"2018-09-17T10:25:52Z","git_url":"git://github.com/JohnAZoidberg/u-root.git","ssh_url":"git@github.com:JohnAZoidberg/u-root.git","clone_url":"https://github.com/JohnAZoidberg/u-root.git","svn_url":"https://github.com/JohnAZoidberg/u-root","homepage":"https://u-root.tk","size":36947,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"u-root:master","ref":"master","sha":"ba9b0699af820ee1a30edbb6c7d1ade3cf62532f","user":{"login":"u-root","id":13317538,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzMzE3NTM4","avatar_url":"https://avatars3.githubusercontent.com/u/13317538?v=4","gravatar_id":"","url":"https://api.github.com/users/u-root","html_url":"https://github.com/u-root","followers_url":"https://api.github.com/users/u-root/followers","following_url":"https://api.github.com/users/u-root/following{/other_user}","gists_url":"https://api.github.com/users/u-root/gists{/gist_id}","starred_url":"https://api.github.com/users/u-root/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/u-root/subscriptions","organizations_url":"https://api.github.com/users/u-root/orgs","repos_url":"https://api.github.com/users/u-root/repos","events_url":"https://api.github.com/users/u-root/events{/privacy}","received_events_url":"https://api.github.com/users/u-root/received_events","type":"Organization","site_admin":false},"repo":{"id":46462030,"node_id":"MDEwOlJlcG9zaXRvcnk0NjQ2MjAzMA==","name":"u-root","full_name":"u-root/u-root","private":false,"owner":{"login":"u-root","id":13317538,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzMzE3NTM4","avatar_url":"https://avatars3.githubusercontent.com/u/13317538?v=4","gravatar_id":"","url":"https://api.github.com/users/u-root","html_url":"https://github.com/u-root","followers_url":"https://api.github.com/users/u-root/followers","following_url":"https://api.github.com/users/u-root/following{/other_user}","gists_url":"https://api.github.com/users/u-root/gists{/gist_id}","starred_url":"https://api.github.com/users/u-root/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/u-root/subscriptions","organizations_url":"https://api.github.com/users/u-root/orgs","repos_url":"https://api.github.com/users/u-root/repos","events_url":"https://api.github.com/users/u-root/events{/privacy}","received_events_url":"https://api.github.com/users/u-root/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/u-root/u-root","description":"A fully Go userland! u-root can create a root file system (initramfs) containing a busybox-like set of tools written in Go.","fork":false,"url":"https://api.github.com/repos/u-root/u-root","forks_url":"https://api.github.com/repos/u-root/u-root/forks","keys_url":"https://api.github.com/repos/u-root/u-root/keys{/key_id}","collaborators_url":"https://api.github.com/repos/u-root/u-root/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/u-root/u-root/teams","hooks_url":"https://api.github.com/repos/u-root/u-root/hooks","issue_events_url":"https://api.github.com/repos/u-root/u-root/issues/events{/number}","events_url":"https://api.github.com/repos/u-root/u-root/events","assignees_url":"https://api.github.com/repos/u-root/u-root/assignees{/user}","branches_url":"https://api.github.com/repos/u-root/u-root/branches{/branch}","tags_url":"https://api.github.com/repos/u-root/u-root/tags","blobs_url":"https://api.github.com/repos/u-root/u-root/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/u-root/u-root/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/u-root/u-root/git/refs{/sha}","trees_url":"https://api.github.com/repos/u-root/u-root/git/trees{/sha}","statuses_url":"https://api.github.com/repos/u-root/u-root/statuses/{sha}","languages_url":"https://api.github.com/repos/u-root/u-root/languages","stargazers_url":"https://api.github.com/repos/u-root/u-root/stargazers","contributors_url":"https://api.github.com/repos/u-root/u-root/contributors","subscribers_url":"https://api.github.com/repos/u-root/u-root/subscribers","subscription_url":"https://api.github.com/repos/u-root/u-root/subscription","commits_url":"https://api.github.com/repos/u-root/u-root/commits{/sha}","git_commits_url":"https://api.github.com/repos/u-root/u-root/git/commits{/sha}","comments_url":"https://api.github.com/repos/u-root/u-root/comments{/number}","issue_comment_url":"https://api.github.com/repos/u-root/u-root/issues/comments{/number}","contents_url":"https://api.github.com/repos/u-root/u-root/contents/{+path}","compare_url":"https://api.github.com/repos/u-root/u-root/compare/{base}...{head}","merges_url":"https://api.github.com/repos/u-root/u-root/merges","archive_url":"https://api.github.com/repos/u-root/u-root/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/u-root/u-root/downloads","issues_url":"https://api.github.com/repos/u-root/u-root/issues{/number}","pulls_url":"https://api.github.com/repos/u-root/u-root/pulls{/number}","milestones_url":"https://api.github.com/repos/u-root/u-root/milestones{/number}","notifications_url":"https://api.github.com/repos/u-root/u-root/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/u-root/u-root/labels{/name}","releases_url":"https://api.github.com/repos/u-root/u-root/releases{/id}","deployments_url":"https://api.github.com/repos/u-root/u-root/deployments","created_at":"2015-11-19T02:28:59Z","updated_at":"2018-09-18T13:52:39Z","pushed_at":"2018-09-18T17:33:20Z","git_url":"git://github.com/u-root/u-root.git","ssh_url":"git@github.com:u-root/u-root.git","clone_url":"https://github.com/u-root/u-root.git","svn_url":"https://github.com/u-root/u-root","homepage":"http://u-root.tk","size":38145,"stargazers_count":762,"watchers_count":762,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":106,"mirror_url":null,"archived":false,"open_issues_count":111,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":106,"open_issues":111,"watchers":762,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/u-root/u-root/pulls/945"},"html":{"href":"https://github.com/u-root/u-root/pull/945"},"issue":{"href":"https://api.github.com/repos/u-root/u-root/issues/945"},"comments":{"href":"https://api.github.com/repos/u-root/u-root/issues/945/comments"},"review_comments":{"href":"https://api.github.com/repos/u-root/u-root/pulls/945/comments"},"review_comment":{"href":"https://api.github.com/repos/u-root/u-root/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/u-root/u-root/pulls/945/commits"},"statuses":{"href":"https://api.github.com/repos/u-root/u-root/statuses/6cb5e5badd8a742c9dff8a6dd1a07a024c81181b"}},"author_association":"NONE"}}
{"actor":{"display_login":"JohnAZoidberg"}}