{"action":"created","comment":{"url":"https://api.github.com/repos/matthiasbeyer/imag/pulls/comments/77830010","id":77830010,"diff_hunk":"@@ -0,0 +1,175 @@\n+use std::path::PathBuf;\n+use std::fmt::{Debug, Formatter, Error as FmtError};\n+use std::result::Result as RResult;\n+\n+use toml::Value;\n+use git2::{Reference as GitReference, Repository, Error as Git2Error};\n+\n+use libimagstore::storeid::StoreId;\n+use libimagstore::hook::Hook;\n+use libimagstore::hook::error::HookError as HE;\n+use libimagstore::hook::error::HookErrorKind as HEK;\n+use libimagstore::hook::error::CustomData as HECD;\n+use libimagstore::hook::result::HookResult;\n+use libimagstore::hook::position::HookPosition;\n+use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider};\n+use libimagstore::hook::accessor::StoreIdAccessor;\n+use libimagerror::trace::trace_error;\n+use libimagerror::into::IntoError;\n+use libimagutil::debug_result::*;\n+\n+use vcs::git::result::Result;\n+use vcs::git::error::MapErrInto;\n+use vcs::git::error::GitHookErrorKind as GHEK;\n+use vcs::git::error::GitHookError as GHE;\n+use vcs::git::runtime::Runtime;\n+\n+pub struct CreateHook {\n+    storepath: PathBuf,\n+\n+    runtime: Runtime,\n+\n+    position: HookPosition,\n+}\n+\n+impl CreateHook {\n+\n+    pub fn new(storepath: PathBuf, p: HookPosition) -> CreateHook {\n+        CreateHook {\n+            runtime: Runtime::new(&storepath),\n+            storepath: storepath,\n+            position: p,\n+        }\n+    }\n+\n+}\n+\n+impl Debug for CreateHook {\n+\n+    fn fmt(&self, fmt: &mut Formatter) -> RResult<(), FmtError> {\n+        write!(fmt, \"CreateHook(storepath={:?}, repository={}, pos={:?}, cfg={:?}\",\n+               self.storepath,\n+               (if self.runtime.has_repository() { \"Some(_)\" } else { \"None\" }),\n+               self.position,\n+               self.runtime.has_config())\n+    }\n+}\n+\n+impl Hook for CreateHook {\n+\n+    fn name(&self) -> &'static str {\n+        \"stdhook_git_create\"\n+    }\n+\n+    fn set_config(&mut self, config: &Value) {\n+        if let Err(e) = self.runtime.set_config(config) {\n+            trace_error(&e);\n+        }\n+    }\n+\n+}\n+\n+impl HookDataAccessorProvider for CreateHook {\n+\n+    fn accessor(&self) -> HookDataAccessor {\n+        HookDataAccessor::StoreIdAccess(self)\n+    }\n+}\n+\n+impl StoreIdAccessor for CreateHook {\n+\n+    fn access(&self, id: &StoreId) -> HookResult<()> {\n+        use vcs::git::action::StoreAction;\n+        use vcs::git::config::commit_message;\n+\n+        debug!(\"[GIT CREATE HOOK]: {:?}\", id);\n+\n+        debug!(\"[GIT CREATE HOOK]: Ensuring branch checkout\");\n+        try!(self\n+             .runtime\n+             .ensure_cfg_branch_is_checked_out()\n+             .map_err(Box::new)\n+             .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e)));\n+        debug!(\"[GIT CREATE HOOK]: Branch checked out\");\n+\n+        self.runtime","path":"libimagstorestdhook/src/vcs/git/create.rs","position":95,"original_position":95,"commit_id":"852ba1bbc70fac0c80ab635a304b69cc0861c12f","original_commit_id":"852ba1bbc70fac0c80ab635a304b69cc0861c12f","user":{"login":"mario-kr","id":7137799,"avatar_url":"https://avatars.githubusercontent.com/u/7137799?v=3","gravatar_id":"","url":"https://api.github.com/users/mario-kr","html_url":"https://github.com/mario-kr","followers_url":"https://api.github.com/users/mario-kr/followers","following_url":"https://api.github.com/users/mario-kr/following{/other_user}","gists_url":"https://api.github.com/users/mario-kr/gists{/gist_id}","starred_url":"https://api.github.com/users/mario-kr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mario-kr/subscriptions","organizations_url":"https://api.github.com/users/mario-kr/orgs","repos_url":"https://api.github.com/users/mario-kr/repos","events_url":"https://api.github.com/users/mario-kr/events{/privacy}","received_events_url":"https://api.github.com/users/mario-kr/received_events","type":"User","site_admin":false},"body":"this huge chain of methods needs some explanation what it actually does and what each part is doing","created_at":"2016-09-07T14:15:35Z","updated_at":"2016-09-07T14:15:35Z","html_url":"https://github.com/matthiasbeyer/imag/pull/486#discussion_r77830010","pull_request_url":"https://api.github.com/repos/matthiasbeyer/imag/pulls/486","_links":{"self":{"href":"https://api.github.com/repos/matthiasbeyer/imag/pulls/comments/77830010"},"html":{"href":"https://github.com/matthiasbeyer/imag/pull/486#discussion_r77830010"},"pull_request":{"href":"https://api.github.com/repos/matthiasbeyer/imag/pulls/486"}}},"pull_request":{"url":"https://api.github.com/repos/matthiasbeyer/imag/pulls/486","id":75770026,"html_url":"https://github.com/matthiasbeyer/imag/pull/486","diff_url":"https://github.com/matthiasbeyer/imag/pull/486.diff","patch_url":"https://github.com/matthiasbeyer/imag/pull/486.patch","issue_url":"https://api.github.com/repos/matthiasbeyer/imag/issues/486","number":486,"state":"open","locked":false,"title":"libimagstorestdhook/git","user":{"login":"matthiasbeyer","id":427866,"avatar_url":"https://avatars.githubusercontent.com/u/427866?v=3","gravatar_id":"","url":"https://api.github.com/users/matthiasbeyer","html_url":"https://github.com/matthiasbeyer","followers_url":"https://api.github.com/users/matthiasbeyer/followers","following_url":"https://api.github.com/users/matthiasbeyer/following{/other_user}","gists_url":"https://api.github.com/users/matthiasbeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/matthiasbeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthiasbeyer/subscriptions","organizations_url":"https://api.github.com/users/matthiasbeyer/orgs","repos_url":"https://api.github.com/users/matthiasbeyer/repos","events_url":"https://api.github.com/users/matthiasbeyer/events{/privacy}","received_events_url":"https://api.github.com/users/matthiasbeyer/received_events","type":"User","site_admin":false},"body":"The #187 follow up.\r\n\r\nImplementation of a git hook which automatically commits and so on. Basic functionality will be implemented here, more will follow in followup-prs.","created_at":"2016-06-30T07:09:34Z","updated_at":"2016-09-07T14:15:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b71942a13e18cef383650fa68b7c2ba8154926ce","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/matthiasbeyer/imag/milestones/2","html_url":"https://github.com/matthiasbeyer/imag/milestones/0.2.0","labels_url":"https://api.github.com/repos/matthiasbeyer/imag/milestones/2/labels","id":1960223,"number":2,"title":"0.2.0","description":"A intermediate release containing _some_ functionality which could be tested by potential users and/or contributors.\r\n\r\nThis cannot be expected to be stable at all. It is more like a starting point for potential reviewers/developers/users and other interested people to have a closer look and also to generate some more feedback from the Rust community to steer the project a bit less loosely.","creator":{"login":"matthiasbeyer","id":427866,"avatar_url":"https://avatars.githubusercontent.com/u/427866?v=3","gravatar_id":"","url":"https://api.github.com/users/matthiasbeyer","html_url":"https://github.com/matthiasbeyer","followers_url":"https://api.github.com/users/matthiasbeyer/followers","following_url":"https://api.github.com/users/matthiasbeyer/following{/other_user}","gists_url":"https://api.github.com/users/matthiasbeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/matthiasbeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthiasbeyer/subscriptions","organizations_url":"https://api.github.com/users/matthiasbeyer/orgs","repos_url":"https://api.github.com/users/matthiasbeyer/repos","events_url":"https://api.github.com/users/matthiasbeyer/events{/privacy}","received_events_url":"https://api.github.com/users/matthiasbeyer/received_events","type":"User","site_admin":false},"open_issues":10,"closed_issues":16,"state":"open","created_at":"2016-08-24T10:53:50Z","updated_at":"2016-09-05T18:30:44Z","due_on":"2016-12-31T00:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/matthiasbeyer/imag/pulls/486/commits","review_comments_url":"https://api.github.com/repos/matthiasbeyer/imag/pulls/486/comments","review_comment_url":"https://api.github.com/repos/matthiasbeyer/imag/pulls/comments{/number}","comments_url":"https://api.github.com/repos/matthiasbeyer/imag/issues/486/comments","statuses_url":"https://api.github.com/repos/matthiasbeyer/imag/statuses/852ba1bbc70fac0c80ab635a304b69cc0861c12f","head":{"label":"matthiasbeyer:libimagstorestdhook/git","ref":"libimagstorestdhook/git","sha":"852ba1bbc70fac0c80ab635a304b69cc0861c12f","user":{"login":"matthiasbeyer","id":427866,"avatar_url":"https://avatars.githubusercontent.com/u/427866?v=3","gravatar_id":"","url":"https://api.github.com/users/matthiasbeyer","html_url":"https://github.com/matthiasbeyer","followers_url":"https://api.github.com/users/matthiasbeyer/followers","following_url":"https://api.github.com/users/matthiasbeyer/following{/other_user}","gists_url":"https://api.github.com/users/matthiasbeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/matthiasbeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthiasbeyer/subscriptions","organizations_url":"https://api.github.com/users/matthiasbeyer/orgs","repos_url":"https://api.github.com/users/matthiasbeyer/repos","events_url":"https://api.github.com/users/matthiasbeyer/events{/privacy}","received_events_url":"https://api.github.com/users/matthiasbeyer/received_events","type":"User","site_admin":false},"repo":{"id":45788713,"name":"imag","full_name":"matthiasbeyer/imag","owner":{"login":"matthiasbeyer","id":427866,"avatar_url":"https://avatars.githubusercontent.com/u/427866?v=3","gravatar_id":"","url":"https://api.github.com/users/matthiasbeyer","html_url":"https://github.com/matthiasbeyer","followers_url":"https://api.github.com/users/matthiasbeyer/followers","following_url":"https://api.github.com/users/matthiasbeyer/following{/other_user}","gists_url":"https://api.github.com/users/matthiasbeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/matthiasbeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthiasbeyer/subscriptions","organizations_url":"https://api.github.com/users/matthiasbeyer/orgs","repos_url":"https://api.github.com/users/matthiasbeyer/repos","events_url":"https://api.github.com/users/matthiasbeyer/events{/privacy}","received_events_url":"https://api.github.com/users/matthiasbeyer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/matthiasbeyer/imag","description":"imag - Text based personal information management suite","fork":false,"url":"https://api.github.com/repos/matthiasbeyer/imag","forks_url":"https://api.github.com/repos/matthiasbeyer/imag/forks","keys_url":"https://api.github.com/repos/matthiasbeyer/imag/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matthiasbeyer/imag/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matthiasbeyer/imag/teams","hooks_url":"https://api.github.com/repos/matthiasbeyer/imag/hooks","issue_events_url":"https://api.github.com/repos/matthiasbeyer/imag/issues/events{/number}","events_url":"https://api.github.com/repos/matthiasbeyer/imag/events","assignees_url":"https://api.github.com/repos/matthiasbeyer/imag/assignees{/user}","branches_url":"https://api.github.com/repos/matthiasbeyer/imag/branches{/branch}","tags_url":"https://api.github.com/repos/matthiasbeyer/imag/tags","blobs_url":"https://api.github.com/repos/matthiasbeyer/imag/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matthiasbeyer/imag/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matthiasbeyer/imag/git/refs{/sha}","trees_url":"https://api.github.com/repos/matthiasbeyer/imag/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matthiasbeyer/imag/statuses/{sha}","languages_url":"https://api.github.com/repos/matthiasbeyer/imag/languages","stargazers_url":"https://api.github.com/repos/matthiasbeyer/imag/stargazers","contributors_url":"https://api.github.com/repos/matthiasbeyer/imag/contributors","subscribers_url":"https://api.github.com/repos/matthiasbeyer/imag/subscribers","subscription_url":"https://api.github.com/repos/matthiasbeyer/imag/subscription","commits_url":"https://api.github.com/repos/matthiasbeyer/imag/commits{/sha}","git_commits_url":"https://api.github.com/repos/matthiasbeyer/imag/git/commits{/sha}","comments_url":"https://api.github.com/repos/matthiasbeyer/imag/comments{/number}","issue_comment_url":"https://api.github.com/repos/matthiasbeyer/imag/issues/comments{/number}","contents_url":"https://api.github.com/repos/matthiasbeyer/imag/contents/{+path}","compare_url":"https://api.github.com/repos/matthiasbeyer/imag/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matthiasbeyer/imag/merges","archive_url":"https://api.github.com/repos/matthiasbeyer/imag/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matthiasbeyer/imag/downloads","issues_url":"https://api.github.com/repos/matthiasbeyer/imag/issues{/number}","pulls_url":"https://api.github.com/repos/matthiasbeyer/imag/pulls{/number}","milestones_url":"https://api.github.com/repos/matthiasbeyer/imag/milestones{/number}","notifications_url":"https://api.github.com/repos/matthiasbeyer/imag/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matthiasbeyer/imag/labels{/name}","releases_url":"https://api.github.com/repos/matthiasbeyer/imag/releases{/id}","deployments_url":"https://api.github.com/repos/matthiasbeyer/imag/deployments","created_at":"2015-11-08T16:34:25Z","updated_at":"2016-09-05T02:18:36Z","pushed_at":"2016-09-07T13:53:39Z","git_url":"git://github.com/matthiasbeyer/imag.git","ssh_url":"git@github.com:matthiasbeyer/imag.git","clone_url":"https://github.com/matthiasbeyer/imag.git","svn_url":"https://github.com/matthiasbeyer/imag","homepage":"http://imag-pim.org","size":9235,"stargazers_count":113,"watchers_count":113,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":17,"mirror_url":null,"open_issues_count":78,"forks":17,"open_issues":78,"watchers":113,"default_branch":"master"}},"base":{"label":"matthiasbeyer:master","ref":"master","sha":"47389f0f24758223612fbd63677f0c80bf93448f","user":{"login":"matthiasbeyer","id":427866,"avatar_url":"https://avatars.githubusercontent.com/u/427866?v=3","gravatar_id":"","url":"https://api.github.com/users/matthiasbeyer","html_url":"https://github.com/matthiasbeyer","followers_url":"https://api.github.com/users/matthiasbeyer/followers","following_url":"https://api.github.com/users/matthiasbeyer/following{/other_user}","gists_url":"https://api.github.com/users/matthiasbeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/matthiasbeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthiasbeyer/subscriptions","organizations_url":"https://api.github.com/users/matthiasbeyer/orgs","repos_url":"https://api.github.com/users/matthiasbeyer/repos","events_url":"https://api.github.com/users/matthiasbeyer/events{/privacy}","received_events_url":"https://api.github.com/users/matthiasbeyer/received_events","type":"User","site_admin":false},"repo":{"id":45788713,"name":"imag","full_name":"matthiasbeyer/imag","owner":{"login":"matthiasbeyer","id":427866,"avatar_url":"https://avatars.githubusercontent.com/u/427866?v=3","gravatar_id":"","url":"https://api.github.com/users/matthiasbeyer","html_url":"https://github.com/matthiasbeyer","followers_url":"https://api.github.com/users/matthiasbeyer/followers","following_url":"https://api.github.com/users/matthiasbeyer/following{/other_user}","gists_url":"https://api.github.com/users/matthiasbeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/matthiasbeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthiasbeyer/subscriptions","organizations_url":"https://api.github.com/users/matthiasbeyer/orgs","repos_url":"https://api.github.com/users/matthiasbeyer/repos","events_url":"https://api.github.com/users/matthiasbeyer/events{/privacy}","received_events_url":"https://api.github.com/users/matthiasbeyer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/matthiasbeyer/imag","description":"imag - Text based personal information management suite","fork":false,"url":"https://api.github.com/repos/matthiasbeyer/imag","forks_url":"https://api.github.com/repos/matthiasbeyer/imag/forks","keys_url":"https://api.github.com/repos/matthiasbeyer/imag/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matthiasbeyer/imag/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matthiasbeyer/imag/teams","hooks_url":"https://api.github.com/repos/matthiasbeyer/imag/hooks","issue_events_url":"https://api.github.com/repos/matthiasbeyer/imag/issues/events{/number}","events_url":"https://api.github.com/repos/matthiasbeyer/imag/events","assignees_url":"https://api.github.com/repos/matthiasbeyer/imag/assignees{/user}","branches_url":"https://api.github.com/repos/matthiasbeyer/imag/branches{/branch}","tags_url":"https://api.github.com/repos/matthiasbeyer/imag/tags","blobs_url":"https://api.github.com/repos/matthiasbeyer/imag/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matthiasbeyer/imag/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matthiasbeyer/imag/git/refs{/sha}","trees_url":"https://api.github.com/repos/matthiasbeyer/imag/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matthiasbeyer/imag/statuses/{sha}","languages_url":"https://api.github.com/repos/matthiasbeyer/imag/languages","stargazers_url":"https://api.github.com/repos/matthiasbeyer/imag/stargazers","contributors_url":"https://api.github.com/repos/matthiasbeyer/imag/contributors","subscribers_url":"https://api.github.com/repos/matthiasbeyer/imag/subscribers","subscription_url":"https://api.github.com/repos/matthiasbeyer/imag/subscription","commits_url":"https://api.github.com/repos/matthiasbeyer/imag/commits{/sha}","git_commits_url":"https://api.github.com/repos/matthiasbeyer/imag/git/commits{/sha}","comments_url":"https://api.github.com/repos/matthiasbeyer/imag/comments{/number}","issue_comment_url":"https://api.github.com/repos/matthiasbeyer/imag/issues/comments{/number}","contents_url":"https://api.github.com/repos/matthiasbeyer/imag/contents/{+path}","compare_url":"https://api.github.com/repos/matthiasbeyer/imag/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matthiasbeyer/imag/merges","archive_url":"https://api.github.com/repos/matthiasbeyer/imag/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matthiasbeyer/imag/downloads","issues_url":"https://api.github.com/repos/matthiasbeyer/imag/issues{/number}","pulls_url":"https://api.github.com/repos/matthiasbeyer/imag/pulls{/number}","milestones_url":"https://api.github.com/repos/matthiasbeyer/imag/milestones{/number}","notifications_url":"https://api.github.com/repos/matthiasbeyer/imag/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matthiasbeyer/imag/labels{/name}","releases_url":"https://api.github.com/repos/matthiasbeyer/imag/releases{/id}","deployments_url":"https://api.github.com/repos/matthiasbeyer/imag/deployments","created_at":"2015-11-08T16:34:25Z","updated_at":"2016-09-05T02:18:36Z","pushed_at":"2016-09-07T13:53:39Z","git_url":"git://github.com/matthiasbeyer/imag.git","ssh_url":"git@github.com:matthiasbeyer/imag.git","clone_url":"https://github.com/matthiasbeyer/imag.git","svn_url":"https://github.com/matthiasbeyer/imag","homepage":"http://imag-pim.org","size":9235,"stargazers_count":113,"watchers_count":113,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":17,"mirror_url":null,"open_issues_count":78,"forks":17,"open_issues":78,"watchers":113,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/matthiasbeyer/imag/pulls/486"},"html":{"href":"https://github.com/matthiasbeyer/imag/pull/486"},"issue":{"href":"https://api.github.com/repos/matthiasbeyer/imag/issues/486"},"comments":{"href":"https://api.github.com/repos/matthiasbeyer/imag/issues/486/comments"},"review_comments":{"href":"https://api.github.com/repos/matthiasbeyer/imag/pulls/486/comments"},"review_comment":{"href":"https://api.github.com/repos/matthiasbeyer/imag/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/matthiasbeyer/imag/pulls/486/commits"},"statuses":{"href":"https://api.github.com/repos/matthiasbeyer/imag/statuses/852ba1bbc70fac0c80ab635a304b69cc0861c12f"}}}}
{"actor":{"display_login":"mario-kr"}}