... | ... |
@@ -103,16 +103,16 @@ sub create_work_rep { |
103 | 103 |
Gitprep::Util::run_command(@git_config_user_name) |
104 | 104 |
or croak "Can't execute git config: @git_config_user_name"; |
105 | 105 |
|
106 |
- # Set user mail |
|
107 |
- my $user_mail = $self->app->dbi->model('user')->select('mail', where => {id => $user})->value; |
|
108 |
- my @git_config_user_mail = $self->app->git->cmd( |
|
106 |
+ # Set user email |
|
107 |
+ my $user_email = $self->app->dbi->model('user')->select('email', where => {id => $user})->value; |
|
108 |
+ my @git_config_user_email = $self->app->git->cmd( |
|
109 | 109 |
$work_rep_info, |
110 | 110 |
'config', |
111 | 111 |
'user.email', |
112 |
- "$user_mail" |
|
112 |
+ "$user_email" |
|
113 | 113 |
); |
114 |
- Gitprep::Util::run_command(@git_config_user_mail) |
|
115 |
- or croak "Can't execute git config: @git_config_user_mail"; |
|
114 |
+ Gitprep::Util::run_command(@git_config_user_email) |
|
115 |
+ or croak "Can't execute git config: @git_config_user_email"; |
|
116 | 116 |
} |
117 | 117 |
} |
118 | 118 |
|
... | ... |
@@ -406,21 +406,6 @@ sub is_database_v1 { |
406 | 406 |
return $is_v1; |
407 | 407 |
} |
408 | 408 |
|
409 |
-=pod |
|
410 |
- # If mail is empty, id is copied to mail for uniqueness |
|
411 |
- my $user_ids = $dbi->select('id', table => 'user', where => {mail => ''})->values; |
|
412 |
- for my $user_id (@$user_ids) { |
|
413 |
- $dbi->update({mail => "$user_id\@gitprep.example"}, table => 'user', where => {id => $user_id}); |
|
414 |
- } |
|
415 |
- |
|
416 |
- # add unique to mail |
|
417 |
- eval { $dbi->execute("create unique index user__mail on user(mail)") }; |
|
418 |
- my $created_user_mail_index = $dbi->execute("select * from sqlite_master where type = 'index' and name = 'user__mail'")->one; |
|
419 |
- unless ($created_user_mail_index) { |
|
420 |
- croak "Can't create user__mail index"; |
|
421 |
- } |
|
422 |
-=cut |
|
423 |
- |
|
424 | 409 |
sub setup_database { |
425 | 410 |
my $self = shift; |
426 | 411 |
|
... | ... |
@@ -578,228 +563,6 @@ EOS |
578 | 563 |
} |
579 | 564 |
} |
580 | 565 |
|
581 |
-=pod |
|
582 |
-sub setup_database_v1 { |
|
583 |
- my $self = shift; |
|
584 |
- |
|
585 |
- my $dbi = $self->app->dbi; |
|
586 |
- |
|
587 |
- # Create user table |
|
588 |
- eval { |
|
589 |
- my $sql = <<"EOS"; |
|
590 |
-create table user ( |
|
591 |
- row_id integer primary key autoincrement, |
|
592 |
- id not null unique default '' |
|
593 |
-); |
|
594 |
-EOS |
|
595 |
- $dbi->execute($sql); |
|
596 |
- }; |
|
597 |
- |
|
598 |
- # Check mail column |
|
599 |
- my $not_exists_user_mail; |
|
600 |
- eval { $dbi->select('mail', table => 'user') }; |
|
601 |
- if ($@) { |
|
602 |
- $not_exists_user_mail = 1; |
|
603 |
- } |
|
604 |
- |
|
605 |
- # Create user columns |
|
606 |
- my $user_columns = [ |
|
607 |
- "admin not null default '0'", |
|
608 |
- "password not null default ''", |
|
609 |
- "salt not null default ''", |
|
610 |
- "mail not null default ''", |
|
611 |
- "name not null default ''" |
|
612 |
- ]; |
|
613 |
- for my $column (@$user_columns) { |
|
614 |
- eval { $dbi->execute("alter table user add column $column") }; |
|
615 |
- } |
|
616 |
- |
|
617 |
- # Check user table |
|
618 |
- eval { $dbi->select([qw/row_id id admin password salt mail name/], table => 'user') }; |
|
619 |
- if ($@) { |
|
620 |
- my $error = "Can't create user table properly: $@"; |
|
621 |
- $self->app->log->error($error); |
|
622 |
- croak $error; |
|
623 |
- } |
|
624 |
- |
|
625 |
- # If mail is empty, id is copied to mail for uniqueness |
|
626 |
- my $user_ids = $dbi->select('id', table => 'user', where => {mail => ''})->values; |
|
627 |
- for my $user_id (@$user_ids) { |
|
628 |
- $dbi->update({mail => "$user_id\@gitprep.example"}, table => 'user', where => {id => $user_id}); |
|
629 |
- } |
|
630 |
- |
|
631 |
- # add unique to mail |
|
632 |
- eval { $dbi->execute("create unique index user__mail on user(mail)") }; |
|
633 |
- my $created_user_mail_index = $dbi->execute("select * from sqlite_master where type = 'index' and name = 'user__mail'")->one; |
|
634 |
- unless ($created_user_mail_index) { |
|
635 |
- croak "Can't create user__mail index"; |
|
636 |
- } |
|
637 |
- |
|
638 |
- # Create ssh_public_key table |
|
639 |
- eval { |
|
640 |
- my $sql = <<"EOS"; |
|
641 |
-create table ssh_public_key ( |
|
642 |
- row_id integer primary key autoincrement, |
|
643 |
- key not null unique default '' |
|
644 |
-); |
|
645 |
-EOS |
|
646 |
- $dbi->execute($sql); |
|
647 |
- }; |
|
648 |
- |
|
649 |
- # Create ssh_public_key columns |
|
650 |
- my $ssh_public_key_columns = [ |
|
651 |
- "user_id not null default ''", |
|
652 |
- "title not null default ''" |
|
653 |
- ]; |
|
654 |
- for my $column (@$ssh_public_key_columns) { |
|
655 |
- eval { $dbi->execute("alter table ssh_public_key add column $column") }; |
|
656 |
- } |
|
657 |
- |
|
658 |
- # Check ssh_public_key table |
|
659 |
- eval { $dbi->select([qw/row_id user_id key title/], table => 'ssh_public_key') }; |
|
660 |
- if ($@) { |
|
661 |
- my $error = "Can't create ssh_public_key table properly: $@"; |
|
662 |
- $self->app->log->error($error); |
|
663 |
- croak $error; |
|
664 |
- } |
|
665 |
- |
|
666 |
- # Create project table |
|
667 |
- eval { |
|
668 |
- my $sql = <<"EOS"; |
|
669 |
-create table project ( |
|
670 |
- row_id integer primary key autoincrement, |
|
671 |
- user_id not null, |
|
672 |
- name not null, |
|
673 |
- unique(user_id, name) |
|
674 |
-); |
|
675 |
-EOS |
|
676 |
- $dbi->execute($sql); |
|
677 |
- }; |
|
678 |
- |
|
679 |
- # Create Project columns |
|
680 |
- my $project_columns = [ |
|
681 |
- "default_branch not null default 'master'", |
|
682 |
- "original_user not null default ''", |
|
683 |
- "original_project integer not null default 0", |
|
684 |
- "private not null default 0", |
|
685 |
- "ignore_space_change not null default 0", |
|
686 |
- "guess_encoding not null default ''" |
|
687 |
- ]; |
|
688 |
- for my $column (@$project_columns) { |
|
689 |
- eval { $dbi->execute("alter table project add column $column") }; |
|
690 |
- } |
|
691 |
- |
|
692 |
- # Check project table |
|
693 |
- eval { |
|
694 |
- $dbi->select( |
|
695 |
- [qw/default_branch original_user original_project private ignore_space_change guess_encoding/], |
|
696 |
- table => 'project' |
|
697 |
- ); |
|
698 |
- }; |
|
699 |
- if ($@) { |
|
700 |
- my $error = "Can't create project table properly: $@"; |
|
701 |
- $self->app->log->error($error); |
|
702 |
- croak $error; |
|
703 |
- } |
|
704 |
- |
|
705 |
- # Create collaboration table |
|
706 |
- eval { |
|
707 |
- my $sql = <<"EOS"; |
|
708 |
-create table collaboration ( |
|
709 |
- row_id integer primary key autoincrement, |
|
710 |
- user_id not null default '', |
|
711 |
- project_name not null default '', |
|
712 |
- collaborator_id not null default '', |
|
713 |
- unique(user_id, project_name, collaborator_id) |
|
714 |
-); |
|
715 |
-EOS |
|
716 |
- $dbi->execute($sql); |
|
717 |
- }; |
|
718 |
- |
|
719 |
- # Check collaboration table |
|
720 |
- eval { $dbi->select([qw/row_id user_id project_name collaborator_id/], table => 'collaboration') }; |
|
721 |
- if ($@) { |
|
722 |
- my $error = "Can't create collaboration table properly: $@"; |
|
723 |
- $self->app->log->error($error); |
|
724 |
- croak $error; |
|
725 |
- } |
|
726 |
- |
|
727 |
- # Create number table |
|
728 |
- eval { |
|
729 |
- my $sql = <<"EOS"; |
|
730 |
-create table number ( |
|
731 |
- row_id integer primary key autoincrement, |
|
732 |
- key not null unique |
|
733 |
-); |
|
734 |
-EOS |
|
735 |
- $dbi->execute($sql); |
|
736 |
- }; |
|
737 |
- |
|
738 |
- # Create number columns |
|
739 |
- my $number_columns = [ |
|
740 |
- "value integer not null default '0'" |
|
741 |
- ]; |
|
742 |
- for my $column (@$number_columns) { |
|
743 |
- eval { $dbi->execute("alter table number add column $column") }; |
|
744 |
- } |
|
745 |
- |
|
746 |
- # Check number table |
|
747 |
- eval { $dbi->select([qw/row_id key value/], table => 'number') }; |
|
748 |
- if ($@) { |
|
749 |
- my $error = "Can't create number table properly: $@"; |
|
750 |
- $self->app->log->error($error); |
|
751 |
- croak $error; |
|
752 |
- } |
|
753 |
- |
|
754 |
- # Original project id number |
|
755 |
- eval { $dbi->insert({key => 'original_project'}, table => 'number') }; |
|
756 |
- my $original_project = $dbi->select( |
|
757 |
- 'key', |
|
758 |
- table => 'number', |
|
759 |
- where => {key => 'original_project'} |
|
760 |
- )->value; |
|
761 |
- unless (defined $original_project) { |
|
762 |
- my $error = "Can't create original_project row in number table"; |
|
763 |
- $self->app->log->error($error); |
|
764 |
- croak $error; |
|
765 |
- } |
|
766 |
- |
|
767 |
- # Create pull_request table |
|
768 |
- eval { |
|
769 |
- my $sql = <<"EOS"; |
|
770 |
-create table pull_request ( |
|
771 |
- row_id integer primary key autoincrement, |
|
772 |
- project integer not null default 0, |
|
773 |
- branch1 not null default '', |
|
774 |
- branch2 not null default '', |
|
775 |
- unique(project, branch1, branch2) |
|
776 |
-); |
|
777 |
-EOS |
|
778 |
- $dbi->execute($sql); |
|
779 |
- }; |
|
780 |
- |
|
781 |
- # Create pull_request columns |
|
782 |
- my @pull_request_columns = ( |
|
783 |
- "title not null default ''", |
|
784 |
- "message not null default ''", |
|
785 |
- "open integer default 0", |
|
786 |
- "open_time integer default 0", |
|
787 |
- "open_user integer default 0" |
|
788 |
- ); |
|
789 |
- for my $column (@pull_request_columns) { |
|
790 |
- eval { $dbi->execute("alter table pull_request add column $column") }; |
|
791 |
- } |
|
792 |
- |
|
793 |
- # Check pull_request table |
|
794 |
- eval { $dbi->select([qw/row_id project branch1 branch2 title message open open_time open_user/], table => 'pull_request') }; |
|
795 |
- if ($@) { |
|
796 |
- my $error = "Can't create pull_request table properly: $@"; |
|
797 |
- $self->app->log->error($error); |
|
798 |
- croak $error; |
|
799 |
- } |
|
800 |
-} |
|
801 |
-=cut |
|
802 |
- |
|
803 | 566 |
sub update_authorized_keys_file { |
804 | 567 |
my $self = shift; |
805 | 568 |
|
... | ... |
@@ -1043,16 +806,16 @@ sub _create_rep { |
1043 | 806 |
Gitprep::Util::run_command(@git_config_user_name) |
1044 | 807 |
or croak "Can't execute git config: @git_config_user_name"; |
1045 | 808 |
|
1046 |
- # Set user mail |
|
1047 |
- my $user_mail = $self->app->dbi->model('user')->select('mail', where => {id => $user})->value; |
|
1048 |
- my @git_config_user_mail = $git->cmd( |
|
809 |
+ # Set user email |
|
810 |
+ my $user_email = $self->app->dbi->model('user')->select('email', where => {id => $user})->value; |
|
811 |
+ my @git_config_user_email = $git->cmd( |
|
1049 | 812 |
$work_rep_info, |
1050 | 813 |
'config', |
1051 | 814 |
'user.email', |
1052 |
- "$user_mail" |
|
815 |
+ "$user_email" |
|
1053 | 816 |
); |
1054 |
- Gitprep::Util::run_command(@git_config_user_mail) |
|
1055 |
- or croak "Can't execute git config: @git_config_user_mail"; |
|
817 |
+ Gitprep::Util::run_command(@git_config_user_email) |
|
818 |
+ or croak "Can't execute git config: @git_config_user_email"; |
|
1056 | 819 |
|
1057 | 820 |
# Commit |
1058 | 821 |
my @git_commit_cmd = $git->cmd( |