{"action":"created","comment":{"url":"https://api.github.com/repos/ledgersmb/LedgerSMB/pulls/comments/53569025","id":53569025,"diff_hunk":"@@ -0,0 +1,176 @@\n+=head1 NAME\n+\n+LedgerSMB::Database::Loadorder - LOADORDER parsing\n+\n+=cut\n+\n+package LedgerSMB::Database::Loadorder;\n+use strict;\n+use warnings;\n+\n+use LedgerSMB::Database::Change;\n+use Cwd;\n+\n+=head1 SYNOPSIS\n+\n+my $loadorder = LedgerSMB::Database::Loadorder->new('path/to/loadorder');\n+my @scripts = $loadorder->scripts;\n+\n+# to make an index of scripts and their sha hashes for db revision checking:\n+\n+$loadorder->makeindex()\n+\n+But see the notes about locking below\n+\n+=head1 METHODS\n+\n+=head2 constructor\n+\n+LedgerSMB::Database::Loadorder->new($path);\n+\n+=cut\n+\n+sub new {\n+    my ($package, $path) = @_;\n+    bless {_path => $path }, $package;\n+}\n+\n+=head2 scripts\n+\n+Returns a list of LedgerSMB::Database::Change objects\n+\n+=cut\n+\n+my $reload_subsequent;\n+sub scripts {\n+    my ($self) = @_;\n+    return @{$self->{_scripts}} if $self->{_scripts};\n+    my $loadorder;\n+    local $!;\n+    local $@;\n+    open(LOAD, '<', $self->{_path}) or\n+        die 'FileError on ' . Cwd::abs_path($self->{_path}) . \": $!\";\n+    $reload_subsequent = 0;\n+    my @scripts =\n+       map { $self->_process_script($_)}\n+       grep { $_ =~ /\\S/ }\n+       map { my $string = $_; $string =~ s/#.*$//; $string }\n+       <LOAD>;\n+    close LOAD;\n+    $self->{_scripts} = \\@scripts;\n+    $reload_subsequent = 0;\n+    return @scripts;\n+}\n+\n+sub _process_script {\n+    my ($self, $line) = @_;\n+    chomp($line);\n+    my $sigil = '';\n+    if ($line =~ /^([!^]+)/){\n+        $sigil = $1 if $1;\n+        $line =~ s/^\\Q$sigil\\E//;\n+    }\n+    $reload_subsequent ||= ( $sigil =~ /\\Q^\\E/ );\n+    my $no_transactions = ( $sigil =~ /\\Q!\\E/ );\n+    return LedgerSMB::Database::Change->new(\n+        $self->path($line),\n+        {\n+            reload_subsequent => $reload_subsequent,\n+            no_transactions => $no_transactions\n+        },\n+    );\n+}\n+\n+=head2 makeindex\n+\n+Creates an index of the files at $path/LOADORDER.idx and locks the file.\n+\n+If the file is already locks throws an error \"LockError\"\n+\n+The LOADORDER.idx remains empty.\n+\n+=cut\n+\n+sub makeindex {\n+    my ($self) = @_;\n+    die 'LockError' if -f $self->path('LOADORDER.idx');\n+    open TEMP, '>', $self->path('LOADORDER.idx');","path":"LedgerSMB/Database/Loadorder.pm","position":97,"original_position":97,"commit_id":"b1b91b0470e557a998759b0965385c7178520856","original_commit_id":"b1b91b0470e557a998759b0965385c7178520856","user":{"login":"ehuelsmann","id":2326559,"avatar_url":"https://avatars.githubusercontent.com/u/2326559?v=3","gravatar_id":"","url":"https://api.github.com/users/ehuelsmann","html_url":"https://github.com/ehuelsmann","followers_url":"https://api.github.com/users/ehuelsmann/followers","following_url":"https://api.github.com/users/ehuelsmann/following{/other_user}","gists_url":"https://api.github.com/users/ehuelsmann/gists{/gist_id}","starred_url":"https://api.github.com/users/ehuelsmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ehuelsmann/subscriptions","organizations_url":"https://api.github.com/users/ehuelsmann/orgs","repos_url":"https://api.github.com/users/ehuelsmann/repos","events_url":"https://api.github.com/users/ehuelsmann/events{/privacy}","received_events_url":"https://api.github.com/users/ehuelsmann/received_events","type":"User","site_admin":false},"body":"This is a race condition. Can't we \"create, fail if exists\"?","created_at":"2016-02-21T16:35:14Z","updated_at":"2016-02-21T16:35:14Z","html_url":"https://github.com/ledgersmb/LedgerSMB/pull/1347#discussion_r53569025","pull_request_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/pulls/1347","_links":{"self":{"href":"https://api.github.com/repos/ledgersmb/LedgerSMB/pulls/comments/53569025"},"html":{"href":"https://github.com/ledgersmb/LedgerSMB/pull/1347#discussion_r53569025"},"pull_request":{"href":"https://api.github.com/repos/ledgersmb/LedgerSMB/pulls/1347"}}},"pull_request":{"url":"https://api.github.com/repos/ledgersmb/LedgerSMB/pulls/1347","id":59842556,"html_url":"https://github.com/ledgersmb/LedgerSMB/pull/1347","diff_url":"https://github.com/ledgersmb/LedgerSMB/pull/1347.diff","patch_url":"https://github.com/ledgersmb/LedgerSMB/pull/1347.patch","issue_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/issues/1347","number":1347,"state":"open","locked":false,"title":"initial outline of db update framework with tests, Fixes #840","user":{"login":"einhverfr","id":341143,"avatar_url":"https://avatars.githubusercontent.com/u/341143?v=3","gravatar_id":"","url":"https://api.github.com/users/einhverfr","html_url":"https://github.com/einhverfr","followers_url":"https://api.github.com/users/einhverfr/followers","following_url":"https://api.github.com/users/einhverfr/following{/other_user}","gists_url":"https://api.github.com/users/einhverfr/gists{/gist_id}","starred_url":"https://api.github.com/users/einhverfr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/einhverfr/subscriptions","organizations_url":"https://api.github.com/users/einhverfr/orgs","repos_url":"https://api.github.com/users/einhverfr/repos","events_url":"https://api.github.com/users/einhverfr/events{/privacy}","received_events_url":"https://api.github.com/users/einhverfr/received_events","type":"User","site_admin":false},"body":"Unit tests only, no integration tests yet, not worked into the framework yet.","created_at":"2016-02-18T18:32:05Z","updated_at":"2016-02-21T16:35:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e1735008225f2fb9821c0281f4b2fd6b03c264c4","assignee":null,"milestone":{"url":"https://api.github.com/repos/ledgersmb/LedgerSMB/milestones/18","html_url":"https://github.com/ledgersmb/LedgerSMB/milestones/1.5-beta4","labels_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/milestones/18/labels","id":1408751,"number":18,"title":"1.5-beta4","description":"","creator":{"login":"einhverfr","id":341143,"avatar_url":"https://avatars.githubusercontent.com/u/341143?v=3","gravatar_id":"","url":"https://api.github.com/users/einhverfr","html_url":"https://github.com/einhverfr","followers_url":"https://api.github.com/users/einhverfr/followers","following_url":"https://api.github.com/users/einhverfr/following{/other_user}","gists_url":"https://api.github.com/users/einhverfr/gists{/gist_id}","starred_url":"https://api.github.com/users/einhverfr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/einhverfr/subscriptions","organizations_url":"https://api.github.com/users/einhverfr/orgs","repos_url":"https://api.github.com/users/einhverfr/repos","events_url":"https://api.github.com/users/einhverfr/events{/privacy}","received_events_url":"https://api.github.com/users/einhverfr/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":4,"state":"open","created_at":"2015-11-12T16:25:45Z","updated_at":"2016-02-19T15:53:52Z","due_on":"2016-01-29T23:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/pulls/1347/commits","review_comments_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/pulls/1347/comments","review_comment_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/issues/1347/comments","statuses_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/statuses/b1b91b0470e557a998759b0965385c7178520856","head":{"label":"einhverfr:master-dbupdate","ref":"master-dbupdate","sha":"b1b91b0470e557a998759b0965385c7178520856","user":{"login":"einhverfr","id":341143,"avatar_url":"https://avatars.githubusercontent.com/u/341143?v=3","gravatar_id":"","url":"https://api.github.com/users/einhverfr","html_url":"https://github.com/einhverfr","followers_url":"https://api.github.com/users/einhverfr/followers","following_url":"https://api.github.com/users/einhverfr/following{/other_user}","gists_url":"https://api.github.com/users/einhverfr/gists{/gist_id}","starred_url":"https://api.github.com/users/einhverfr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/einhverfr/subscriptions","organizations_url":"https://api.github.com/users/einhverfr/orgs","repos_url":"https://api.github.com/users/einhverfr/repos","events_url":"https://api.github.com/users/einhverfr/events{/privacy}","received_events_url":"https://api.github.com/users/einhverfr/received_events","type":"User","site_admin":false},"repo":{"id":18487325,"name":"LedgerSMB","full_name":"einhverfr/LedgerSMB","owner":{"login":"einhverfr","id":341143,"avatar_url":"https://avatars.githubusercontent.com/u/341143?v=3","gravatar_id":"","url":"https://api.github.com/users/einhverfr","html_url":"https://github.com/einhverfr","followers_url":"https://api.github.com/users/einhverfr/followers","following_url":"https://api.github.com/users/einhverfr/following{/other_user}","gists_url":"https://api.github.com/users/einhverfr/gists{/gist_id}","starred_url":"https://api.github.com/users/einhverfr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/einhverfr/subscriptions","organizations_url":"https://api.github.com/users/einhverfr/orgs","repos_url":"https://api.github.com/users/einhverfr/repos","events_url":"https://api.github.com/users/einhverfr/events{/privacy}","received_events_url":"https://api.github.com/users/einhverfr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/einhverfr/LedgerSMB","description":"Master repository for the LedgerSMB project","fork":true,"url":"https://api.github.com/repos/einhverfr/LedgerSMB","forks_url":"https://api.github.com/repos/einhverfr/LedgerSMB/forks","keys_url":"https://api.github.com/repos/einhverfr/LedgerSMB/keys{/key_id}","collaborators_url":"https://api.github.com/repos/einhverfr/LedgerSMB/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/einhverfr/LedgerSMB/teams","hooks_url":"https://api.github.com/repos/einhverfr/LedgerSMB/hooks","issue_events_url":"https://api.github.com/repos/einhverfr/LedgerSMB/issues/events{/number}","events_url":"https://api.github.com/repos/einhverfr/LedgerSMB/events","assignees_url":"https://api.github.com/repos/einhverfr/LedgerSMB/assignees{/user}","branches_url":"https://api.github.com/repos/einhverfr/LedgerSMB/branches{/branch}","tags_url":"https://api.github.com/repos/einhverfr/LedgerSMB/tags","blobs_url":"https://api.github.com/repos/einhverfr/LedgerSMB/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/einhverfr/LedgerSMB/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/einhverfr/LedgerSMB/git/refs{/sha}","trees_url":"https://api.github.com/repos/einhverfr/LedgerSMB/git/trees{/sha}","statuses_url":"https://api.github.com/repos/einhverfr/LedgerSMB/statuses/{sha}","languages_url":"https://api.github.com/repos/einhverfr/LedgerSMB/languages","stargazers_url":"https://api.github.com/repos/einhverfr/LedgerSMB/stargazers","contributors_url":"https://api.github.com/repos/einhverfr/LedgerSMB/contributors","subscribers_url":"https://api.github.com/repos/einhverfr/LedgerSMB/subscribers","subscription_url":"https://api.github.com/repos/einhverfr/LedgerSMB/subscription","commits_url":"https://api.github.com/repos/einhverfr/LedgerSMB/commits{/sha}","git_commits_url":"https://api.github.com/repos/einhverfr/LedgerSMB/git/commits{/sha}","comments_url":"https://api.github.com/repos/einhverfr/LedgerSMB/comments{/number}","issue_comment_url":"https://api.github.com/repos/einhverfr/LedgerSMB/issues/comments{/number}","contents_url":"https://api.github.com/repos/einhverfr/LedgerSMB/contents/{+path}","compare_url":"https://api.github.com/repos/einhverfr/LedgerSMB/compare/{base}...{head}","merges_url":"https://api.github.com/repos/einhverfr/LedgerSMB/merges","archive_url":"https://api.github.com/repos/einhverfr/LedgerSMB/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/einhverfr/LedgerSMB/downloads","issues_url":"https://api.github.com/repos/einhverfr/LedgerSMB/issues{/number}","pulls_url":"https://api.github.com/repos/einhverfr/LedgerSMB/pulls{/number}","milestones_url":"https://api.github.com/repos/einhverfr/LedgerSMB/milestones{/number}","notifications_url":"https://api.github.com/repos/einhverfr/LedgerSMB/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/einhverfr/LedgerSMB/labels{/name}","releases_url":"https://api.github.com/repos/einhverfr/LedgerSMB/releases{/id}","deployments_url":"https://api.github.com/repos/einhverfr/LedgerSMB/deployments","created_at":"2014-04-06T10:38:35Z","updated_at":"2016-02-14T13:05:59Z","pushed_at":"2016-02-21T14:55:19Z","git_url":"git://github.com/einhverfr/LedgerSMB.git","ssh_url":"git@github.com:einhverfr/LedgerSMB.git","clone_url":"https://github.com/einhverfr/LedgerSMB.git","svn_url":"https://github.com/einhverfr/LedgerSMB","homepage":"http://ledgersmb.org","size":48911,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"ledgersmb:master","ref":"master","sha":"526f1d038655328dfa7b362661f1262830ba9f46","user":{"login":"ledgersmb","id":2297436,"avatar_url":"https://avatars.githubusercontent.com/u/2297436?v=3","gravatar_id":"","url":"https://api.github.com/users/ledgersmb","html_url":"https://github.com/ledgersmb","followers_url":"https://api.github.com/users/ledgersmb/followers","following_url":"https://api.github.com/users/ledgersmb/following{/other_user}","gists_url":"https://api.github.com/users/ledgersmb/gists{/gist_id}","starred_url":"https://api.github.com/users/ledgersmb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ledgersmb/subscriptions","organizations_url":"https://api.github.com/users/ledgersmb/orgs","repos_url":"https://api.github.com/users/ledgersmb/repos","events_url":"https://api.github.com/users/ledgersmb/events{/privacy}","received_events_url":"https://api.github.com/users/ledgersmb/received_events","type":"Organization","site_admin":false},"repo":{"id":18471236,"name":"LedgerSMB","full_name":"ledgersmb/LedgerSMB","owner":{"login":"ledgersmb","id":2297436,"avatar_url":"https://avatars.githubusercontent.com/u/2297436?v=3","gravatar_id":"","url":"https://api.github.com/users/ledgersmb","html_url":"https://github.com/ledgersmb","followers_url":"https://api.github.com/users/ledgersmb/followers","following_url":"https://api.github.com/users/ledgersmb/following{/other_user}","gists_url":"https://api.github.com/users/ledgersmb/gists{/gist_id}","starred_url":"https://api.github.com/users/ledgersmb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ledgersmb/subscriptions","organizations_url":"https://api.github.com/users/ledgersmb/orgs","repos_url":"https://api.github.com/users/ledgersmb/repos","events_url":"https://api.github.com/users/ledgersmb/events{/privacy}","received_events_url":"https://api.github.com/users/ledgersmb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ledgersmb/LedgerSMB","description":"Master repository for the LedgerSMB project","fork":false,"url":"https://api.github.com/repos/ledgersmb/LedgerSMB","forks_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/forks","keys_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/teams","hooks_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/hooks","issue_events_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/issues/events{/number}","events_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/events","assignees_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/assignees{/user}","branches_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/branches{/branch}","tags_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/tags","blobs_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/git/refs{/sha}","trees_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/statuses/{sha}","languages_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/languages","stargazers_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/stargazers","contributors_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/contributors","subscribers_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/subscribers","subscription_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/subscription","commits_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/commits{/sha}","git_commits_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/git/commits{/sha}","comments_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/comments{/number}","issue_comment_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/issues/comments{/number}","contents_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/contents/{+path}","compare_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/merges","archive_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/downloads","issues_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/issues{/number}","pulls_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/pulls{/number}","milestones_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/milestones{/number}","notifications_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/labels{/name}","releases_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/releases{/id}","deployments_url":"https://api.github.com/repos/ledgersmb/LedgerSMB/deployments","created_at":"2014-04-05T16:43:59Z","updated_at":"2016-02-15T23:26:50Z","pushed_at":"2016-02-21T08:22:39Z","git_url":"git://github.com/ledgersmb/LedgerSMB.git","ssh_url":"git@github.com:ledgersmb/LedgerSMB.git","clone_url":"https://github.com/ledgersmb/LedgerSMB.git","svn_url":"https://github.com/ledgersmb/LedgerSMB","homepage":"http://ledgersmb.org","size":48746,"stargazers_count":9,"watchers_count":9,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":156,"forks":19,"open_issues":156,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ledgersmb/LedgerSMB/pulls/1347"},"html":{"href":"https://github.com/ledgersmb/LedgerSMB/pull/1347"},"issue":{"href":"https://api.github.com/repos/ledgersmb/LedgerSMB/issues/1347"},"comments":{"href":"https://api.github.com/repos/ledgersmb/LedgerSMB/issues/1347/comments"},"review_comments":{"href":"https://api.github.com/repos/ledgersmb/LedgerSMB/pulls/1347/comments"},"review_comment":{"href":"https://api.github.com/repos/ledgersmb/LedgerSMB/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ledgersmb/LedgerSMB/pulls/1347/commits"},"statuses":{"href":"https://api.github.com/repos/ledgersmb/LedgerSMB/statuses/b1b91b0470e557a998759b0965385c7178520856"}}}}