{"action":"created","comment":{"url":"https://api.github.com/repos/syncthing/syncthing/pulls/comments/26438308","id":26438308,"diff_hunk":"@@ -0,0 +1,95 @@\n+// Copyright (C) 2014 The Syncthing Authors.\n+//\n+// This program is free software: you can redistribute it and/or modify it\n+// under the terms of the GNU General Public License as published by the Free\n+// Software Foundation, either version 3 of the License, or (at your option)\n+// any later version.\n+//\n+// This program is distributed in the hope that it will be useful, but WITHOUT\n+// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\n+// more details.\n+//\n+// You should have received a copy of the GNU General Public License along\n+// with this program. If not, see <http://www.gnu.org/licenses/>.\n+\n+package versioner\n+\n+import (\n+\t\"os\"\n+\t\"os/exec\"\n+\t\"path/filepath\"\n+)\n+\n+func init() {\n+\t// Register the constructor for this type of versioner with the name \"external\"\n+\tFactories[\"external\"] = NewExternal\n+}\n+\n+// The type holds our configuration\n+type External struct {\n+\tcommand    string\n+\tfolderPath string\n+}\n+\n+// The constructor function takes a map of parameters and creates the type.\n+func NewExternal(folderID, folderPath string, params map[string]string) Versioner {\n+\tcommand := params[\"command\"]\n+\n+\ts := External{\n+\t\tcommand:    command,\n+\t\tfolderPath: folderPath,\n+\t}\n+\n+\tif debug {\n+\t\tl.Debugf(\"instantiated %#v\", s)\n+\t}\n+\treturn s\n+}\n+\n+// Move away the named file to a version archive. If this function returns\n+// nil, the named file does not exist any more (has been archived).\n+func (v External) Archive(filePath string) error {\n+\t_, err := os.Lstat(filePath)\n+\tif err != nil {\n+\t\tif os.IsNotExist(err) {\n+\t\t\tif debug {\n+\t\t\t\tl.Debugln(\"not archiving nonexistent file\", filePath)\n+\t\t\t}\n+\t\t\treturn nil\n+\t\t}\n+\t\treturn err\n+\t}\n+\n+\tif debug {\n+\t\tl.Debugln(\"archiving\", filePath)\n+\t}\n+\n+\tinFolderPath, err := filepath.Rel(v.folderPath, filePath)\n+\tif err != nil {\n+\t\treturn err\n+\t}\n+\tif v.command != \"\" {\n+\t\tcmd := exec.Command(v.command, v.folderPath, inFolderPath)\n+\t\tcmd.Env = []string{\"\"}","path":"internal/versioner/external.go","position":74,"original_position":74,"commit_id":"586db69cc0a632c7f81e1d31aff3b5d7c3457b69","original_commit_id":"586db69cc0a632c7f81e1d31aff3b5d7c3457b69","user":{"login":"calmh","id":125426,"avatar_url":"https://avatars.githubusercontent.com/u/125426?v=3","gravatar_id":"","url":"https://api.github.com/users/calmh","html_url":"https://github.com/calmh","followers_url":"https://api.github.com/users/calmh/followers","following_url":"https://api.github.com/users/calmh/following{/other_user}","gists_url":"https://api.github.com/users/calmh/gists{/gist_id}","starred_url":"https://api.github.com/users/calmh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calmh/subscriptions","organizations_url":"https://api.github.com/users/calmh/orgs","repos_url":"https://api.github.com/users/calmh/repos","events_url":"https://api.github.com/users/calmh/events{/privacy}","received_events_url":"https://api.github.com/users/calmh/received_events","type":"User","site_admin":false},"body":"Is this a bit drastic? This erases knowledge of the user's home directory and things like that.","created_at":"2015-03-14T14:38:02Z","updated_at":"2015-03-14T14:38:02Z","html_url":"https://github.com/syncthing/syncthing/pull/1463#discussion_r26438308","pull_request_url":"https://api.github.com/repos/syncthing/syncthing/pulls/1463","_links":{"self":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/comments/26438308"},"html":{"href":"https://github.com/syncthing/syncthing/pull/1463#discussion_r26438308"},"pull_request":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/1463"}}},"pull_request":{"url":"https://api.github.com/repos/syncthing/syncthing/pulls/1463","id":31166098,"html_url":"https://github.com/syncthing/syncthing/pull/1463","diff_url":"https://github.com/syncthing/syncthing/pull/1463.diff","patch_url":"https://github.com/syncthing/syncthing/pull/1463.patch","issue_url":"https://api.github.com/repos/syncthing/syncthing/issues/1463","number":1463,"state":"open","locked":false,"title":"Add external versioner (ref #573)","user":{"login":"alex2108","id":6099511,"avatar_url":"https://avatars.githubusercontent.com/u/6099511?v=3","gravatar_id":"","url":"https://api.github.com/users/alex2108","html_url":"https://github.com/alex2108","followers_url":"https://api.github.com/users/alex2108/followers","following_url":"https://api.github.com/users/alex2108/following{/other_user}","gists_url":"https://api.github.com/users/alex2108/gists{/gist_id}","starred_url":"https://api.github.com/users/alex2108/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alex2108/subscriptions","organizations_url":"https://api.github.com/users/alex2108/orgs","repos_url":"https://api.github.com/users/alex2108/repos","events_url":"https://api.github.com/users/alex2108/events{/privacy}","received_events_url":"https://api.github.com/users/alex2108/received_events","type":"User","site_admin":false},"body":"First part of https://github.com/syncthing/syncthing/issues/573. \r\n\r\nIt expects the external script to delete the file but makes sure it's really deleted and prints a error if it was not. Hope that is fine like this.","created_at":"2015-03-13T21:37:23Z","updated_at":"2015-03-14T14:38:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f69a9fed617911c17043408031c8bf895fd87234","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/syncthing/syncthing/pulls/1463/commits","review_comments_url":"https://api.github.com/repos/syncthing/syncthing/pulls/1463/comments","review_comment_url":"https://api.github.com/repos/syncthing/syncthing/pulls/comments{/number}","comments_url":"https://api.github.com/repos/syncthing/syncthing/issues/1463/comments","statuses_url":"https://api.github.com/repos/syncthing/syncthing/statuses/586db69cc0a632c7f81e1d31aff3b5d7c3457b69","head":{"label":"alex2108:master","ref":"master","sha":"586db69cc0a632c7f81e1d31aff3b5d7c3457b69","user":{"login":"alex2108","id":6099511,"avatar_url":"https://avatars.githubusercontent.com/u/6099511?v=3","gravatar_id":"","url":"https://api.github.com/users/alex2108","html_url":"https://github.com/alex2108","followers_url":"https://api.github.com/users/alex2108/followers","following_url":"https://api.github.com/users/alex2108/following{/other_user}","gists_url":"https://api.github.com/users/alex2108/gists{/gist_id}","starred_url":"https://api.github.com/users/alex2108/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alex2108/subscriptions","organizations_url":"https://api.github.com/users/alex2108/orgs","repos_url":"https://api.github.com/users/alex2108/repos","events_url":"https://api.github.com/users/alex2108/events{/privacy}","received_events_url":"https://api.github.com/users/alex2108/received_events","type":"User","site_admin":false},"repo":{"id":32181425,"name":"syncthing","full_name":"alex2108/syncthing","owner":{"login":"alex2108","id":6099511,"avatar_url":"https://avatars.githubusercontent.com/u/6099511?v=3","gravatar_id":"","url":"https://api.github.com/users/alex2108","html_url":"https://github.com/alex2108","followers_url":"https://api.github.com/users/alex2108/followers","following_url":"https://api.github.com/users/alex2108/following{/other_user}","gists_url":"https://api.github.com/users/alex2108/gists{/gist_id}","starred_url":"https://api.github.com/users/alex2108/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alex2108/subscriptions","organizations_url":"https://api.github.com/users/alex2108/orgs","repos_url":"https://api.github.com/users/alex2108/repos","events_url":"https://api.github.com/users/alex2108/events{/privacy}","received_events_url":"https://api.github.com/users/alex2108/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alex2108/syncthing","description":"Open Source Continuous File Synchronization","fork":true,"url":"https://api.github.com/repos/alex2108/syncthing","forks_url":"https://api.github.com/repos/alex2108/syncthing/forks","keys_url":"https://api.github.com/repos/alex2108/syncthing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alex2108/syncthing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alex2108/syncthing/teams","hooks_url":"https://api.github.com/repos/alex2108/syncthing/hooks","issue_events_url":"https://api.github.com/repos/alex2108/syncthing/issues/events{/number}","events_url":"https://api.github.com/repos/alex2108/syncthing/events","assignees_url":"https://api.github.com/repos/alex2108/syncthing/assignees{/user}","branches_url":"https://api.github.com/repos/alex2108/syncthing/branches{/branch}","tags_url":"https://api.github.com/repos/alex2108/syncthing/tags","blobs_url":"https://api.github.com/repos/alex2108/syncthing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alex2108/syncthing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alex2108/syncthing/git/refs{/sha}","trees_url":"https://api.github.com/repos/alex2108/syncthing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alex2108/syncthing/statuses/{sha}","languages_url":"https://api.github.com/repos/alex2108/syncthing/languages","stargazers_url":"https://api.github.com/repos/alex2108/syncthing/stargazers","contributors_url":"https://api.github.com/repos/alex2108/syncthing/contributors","subscribers_url":"https://api.github.com/repos/alex2108/syncthing/subscribers","subscription_url":"https://api.github.com/repos/alex2108/syncthing/subscription","commits_url":"https://api.github.com/repos/alex2108/syncthing/commits{/sha}","git_commits_url":"https://api.github.com/repos/alex2108/syncthing/git/commits{/sha}","comments_url":"https://api.github.com/repos/alex2108/syncthing/comments{/number}","issue_comment_url":"https://api.github.com/repos/alex2108/syncthing/issues/comments{/number}","contents_url":"https://api.github.com/repos/alex2108/syncthing/contents/{+path}","compare_url":"https://api.github.com/repos/alex2108/syncthing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alex2108/syncthing/merges","archive_url":"https://api.github.com/repos/alex2108/syncthing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alex2108/syncthing/downloads","issues_url":"https://api.github.com/repos/alex2108/syncthing/issues{/number}","pulls_url":"https://api.github.com/repos/alex2108/syncthing/pulls{/number}","milestones_url":"https://api.github.com/repos/alex2108/syncthing/milestones{/number}","notifications_url":"https://api.github.com/repos/alex2108/syncthing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alex2108/syncthing/labels{/name}","releases_url":"https://api.github.com/repos/alex2108/syncthing/releases{/id}","created_at":"2015-03-13T21:19:20Z","updated_at":"2015-03-13T22:43:37Z","pushed_at":"2015-03-13T22:43:37Z","git_url":"git://github.com/alex2108/syncthing.git","ssh_url":"git@github.com:alex2108/syncthing.git","clone_url":"https://github.com/alex2108/syncthing.git","svn_url":"https://github.com/alex2108/syncthing","homepage":"http://discourse.syncthing.net/","size":52585,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"syncthing:master","ref":"master","sha":"1dc5c6b8a8265d431ebcc511a6b065821bd5b413","user":{"login":"syncthing","id":7628018,"avatar_url":"https://avatars.githubusercontent.com/u/7628018?v=3","gravatar_id":"","url":"https://api.github.com/users/syncthing","html_url":"https://github.com/syncthing","followers_url":"https://api.github.com/users/syncthing/followers","following_url":"https://api.github.com/users/syncthing/following{/other_user}","gists_url":"https://api.github.com/users/syncthing/gists{/gist_id}","starred_url":"https://api.github.com/users/syncthing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syncthing/subscriptions","organizations_url":"https://api.github.com/users/syncthing/orgs","repos_url":"https://api.github.com/users/syncthing/repos","events_url":"https://api.github.com/users/syncthing/events{/privacy}","received_events_url":"https://api.github.com/users/syncthing/received_events","type":"Organization","site_admin":false},"repo":{"id":14712850,"name":"syncthing","full_name":"syncthing/syncthing","owner":{"login":"syncthing","id":7628018,"avatar_url":"https://avatars.githubusercontent.com/u/7628018?v=3","gravatar_id":"","url":"https://api.github.com/users/syncthing","html_url":"https://github.com/syncthing","followers_url":"https://api.github.com/users/syncthing/followers","following_url":"https://api.github.com/users/syncthing/following{/other_user}","gists_url":"https://api.github.com/users/syncthing/gists{/gist_id}","starred_url":"https://api.github.com/users/syncthing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/syncthing/subscriptions","organizations_url":"https://api.github.com/users/syncthing/orgs","repos_url":"https://api.github.com/users/syncthing/repos","events_url":"https://api.github.com/users/syncthing/events{/privacy}","received_events_url":"https://api.github.com/users/syncthing/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/syncthing/syncthing","description":"Open Source Continuous File Synchronization","fork":false,"url":"https://api.github.com/repos/syncthing/syncthing","forks_url":"https://api.github.com/repos/syncthing/syncthing/forks","keys_url":"https://api.github.com/repos/syncthing/syncthing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/syncthing/syncthing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/syncthing/syncthing/teams","hooks_url":"https://api.github.com/repos/syncthing/syncthing/hooks","issue_events_url":"https://api.github.com/repos/syncthing/syncthing/issues/events{/number}","events_url":"https://api.github.com/repos/syncthing/syncthing/events","assignees_url":"https://api.github.com/repos/syncthing/syncthing/assignees{/user}","branches_url":"https://api.github.com/repos/syncthing/syncthing/branches{/branch}","tags_url":"https://api.github.com/repos/syncthing/syncthing/tags","blobs_url":"https://api.github.com/repos/syncthing/syncthing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/syncthing/syncthing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/syncthing/syncthing/git/refs{/sha}","trees_url":"https://api.github.com/repos/syncthing/syncthing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/syncthing/syncthing/statuses/{sha}","languages_url":"https://api.github.com/repos/syncthing/syncthing/languages","stargazers_url":"https://api.github.com/repos/syncthing/syncthing/stargazers","contributors_url":"https://api.github.com/repos/syncthing/syncthing/contributors","subscribers_url":"https://api.github.com/repos/syncthing/syncthing/subscribers","subscription_url":"https://api.github.com/repos/syncthing/syncthing/subscription","commits_url":"https://api.github.com/repos/syncthing/syncthing/commits{/sha}","git_commits_url":"https://api.github.com/repos/syncthing/syncthing/git/commits{/sha}","comments_url":"https://api.github.com/repos/syncthing/syncthing/comments{/number}","issue_comment_url":"https://api.github.com/repos/syncthing/syncthing/issues/comments{/number}","contents_url":"https://api.github.com/repos/syncthing/syncthing/contents/{+path}","compare_url":"https://api.github.com/repos/syncthing/syncthing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/syncthing/syncthing/merges","archive_url":"https://api.github.com/repos/syncthing/syncthing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/syncthing/syncthing/downloads","issues_url":"https://api.github.com/repos/syncthing/syncthing/issues{/number}","pulls_url":"https://api.github.com/repos/syncthing/syncthing/pulls{/number}","milestones_url":"https://api.github.com/repos/syncthing/syncthing/milestones{/number}","notifications_url":"https://api.github.com/repos/syncthing/syncthing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/syncthing/syncthing/labels{/name}","releases_url":"https://api.github.com/repos/syncthing/syncthing/releases{/id}","created_at":"2013-11-26T09:48:21Z","updated_at":"2015-03-14T14:10:41Z","pushed_at":"2015-03-13T21:07:34Z","git_url":"git://github.com/syncthing/syncthing.git","ssh_url":"git@github.com:syncthing/syncthing.git","clone_url":"https://github.com/syncthing/syncthing.git","svn_url":"https://github.com/syncthing/syncthing","homepage":"http://discourse.syncthing.net/","size":52585,"stargazers_count":7245,"watchers_count":7245,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":478,"mirror_url":null,"open_issues_count":127,"forks":478,"open_issues":127,"watchers":7245,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/1463"},"html":{"href":"https://github.com/syncthing/syncthing/pull/1463"},"issue":{"href":"https://api.github.com/repos/syncthing/syncthing/issues/1463"},"comments":{"href":"https://api.github.com/repos/syncthing/syncthing/issues/1463/comments"},"review_comments":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/1463/comments"},"review_comment":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/syncthing/syncthing/pulls/1463/commits"},"statuses":{"href":"https://api.github.com/repos/syncthing/syncthing/statuses/586db69cc0a632c7f81e1d31aff3b5d7c3457b69"}}}}