From c250ff7715947cab72e4ddef27501e8e9232cf13 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Wed, 1 Jun 2011 10:46:39 -0500 Subject: [PATCH 1/6] qtbase-earth-staging is no longer used, so remove it --- init-repository | 1 - 1 file changed, 1 deletion(-) diff --git a/init-repository b/init-repository index 9eefd7e8..2d104fde 100755 --- a/init-repository +++ b/init-repository @@ -195,7 +195,6 @@ my %STAGING_REPOS = map { $_ => "git://gitorious.org/qt/$_.git" } qw( qt5-staging qt3support-staging qtactiveqt-staging - qtbase-earth-staging qtbase-staging qtdeclarative-staging qtdoc-staging From 15b148592f003604740fb3fda0ab398b2b125a18 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Wed, 1 Jun 2011 10:52:29 -0500 Subject: [PATCH 2/6] Default to --ignore-submodules for --nokia-developer/--brisbane When you use either --nokia-developer or --brisbane, changes are that you're going to be working on one of the submodules anyways, in which case, having git commands in top-level repo work on submodules too is an annoyance. --- init-repository | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/init-repository b/init-repository index 2d104fde..dd9f7233 100755 --- a/init-repository +++ b/init-repository @@ -98,6 +98,8 @@ Skip the `git submodule update' command. Set git config to ignore submodules by default when doing operations on the qt5 repo, such as `pull', `fetch', `diff' etc. +This option is default for --nokia-developer/--brisbane. + After using this option, pass `--ignore-submodules=none' to git to override it as needed. @@ -282,11 +284,13 @@ sub parse_arguments $self->{'protocol'} = 'internal'; $self->{'mirror-url'} = $BNE_MIRROR_URL_BASE; $self->{'mirror-webkit-url'} = $BNE_MIRROR_WEBKIT_URL; + $self->{'ignore-submodules'} = 1; }, 'nokia-developer' => sub { $self->{'nokia-developer'} = 1; $self->{'protocol'} = 'internal'; + $self->{'ignore-submodules'} = 1; }, ) || pod2usage(2); From 3c8d0ab74eeb32153198f816a732bd016954bc80 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Wed, 1 Jun 2011 11:00:33 -0500 Subject: [PATCH 3/6] Make all staging repos 'staging' remotes in submodules This allows us to more easily use git submodule foreach since you can just refer to staging for the repo, like you would 'origin'. --- init-repository | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/init-repository b/init-repository index dd9f7233..2d4e15cb 100755 --- a/init-repository +++ b/init-repository @@ -193,24 +193,24 @@ my %PROTOCOLS = ( 'http' => 'http://git.gitorious.org/' , ); -my %STAGING_REPOS = map { $_ => "git://gitorious.org/qt/$_.git" } qw( - qt5-staging - qt3support-staging - qtactiveqt-staging - qtbase-staging - qtdeclarative-staging - qtdoc-staging - qtmultimedia-staging - qtphonon-staging - qtqa-staging - qtscript-staging - qtsvg-staging - qttools-staging - qttranslations-staging - qtwebkit-examples-and-demos-staging - qtxmlpatterns-staging - qtlocation-staging - qtsensors-staging +my %STAGING_REPOS = map { $_ => "git://gitorious.org/qt/$_-staging.git" } qw( + qt5 + qt3support + qtactiveqt + qtbase + qtdeclarative + qtdoc + qtmultimedia + qtphonon + qtqa + qtscript + qtsvg + qttools + qttranslations + qtwebkit-examples-and-demos + qtxmlpatterns + qtlocation + qtsensors ); my $BNE_MIRROR_URL_BASE @@ -427,10 +427,7 @@ sub git_add_staging_remote $current_remotes{$line} = 1; } - # We assume that any staging starting with `$repo_basename-' relates to this - # repo. For example, for the `qtbase' module, `qtbase-staging' - # and `qtbase-earth-staging' are considered as related staging repos. - my @staging = grep { /^\Q$repo_basename\E-/; } keys %STAGING_REPOS; + my @staging = grep { /^$repo_basename$/; } keys %STAGING_REPOS; STAGING: foreach my $staging_repo (@staging) { @@ -444,7 +441,7 @@ sub git_add_staging_remote } $staging_repo_url =~ s,^git://gitorious\.org/,$url_base_for_protocol,; } - $self->exe('git', 'remote', 'add', $staging_repo, $staging_repo_url); + $self->exe('git', 'remote', 'add', 'staging', $staging_repo_url); } return; From 5d54ac9bb02e420d28d4b784fc99503c23fbaab1 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Wed, 1 Jun 2011 11:02:53 -0500 Subject: [PATCH 4/6] Remove silly "goto" usage in foreach loop --- init-repository | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/init-repository b/init-repository index 2d4e15cb..999fdf96 100755 --- a/init-repository +++ b/init-repository @@ -366,10 +366,9 @@ sub git_set_submodule_config my $protocol = $self->{protocol}; my $url_base_for_protocol = $PROTOCOLS{$protocol}; - GITCONFIG: foreach my $line (@configresult) { # Example line: submodule.qtqa.url=git://gitorious.org/qt/qtqa.git - next GITCONFIG if ($line !~ /(submodule\.[^.=]+\.url)=(.*)/); + next if ($line !~ /(submodule\.[^.=]+\.url)=(.*)/); my $key = $1; my $value = $2; @@ -429,10 +428,9 @@ sub git_add_staging_remote my @staging = grep { /^$repo_basename$/; } keys %STAGING_REPOS; - STAGING: foreach my $staging_repo (@staging) { # nothing to do if remote already exists - next STAGING if ($current_remotes{$staging_repo}); + next if ($current_remotes{$staging_repo}); my $staging_repo_url = $STAGING_REPOS{$staging_repo}; if ($protocol) { From da3eb5c7ec24e306fce5dabb3988243d8462e44a Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Wed, 1 Jun 2011 12:17:41 -0500 Subject: [PATCH 5/6] Add 'staging' remote to repos which don't have a staging area This makes it simpler to do git submodule foreach commands, since you don't need to worry about the repos without any staging area. --- init-repository | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/init-repository b/init-repository index 999fdf96..47371be0 100755 --- a/init-repository +++ b/init-repository @@ -428,18 +428,30 @@ sub git_add_staging_remote my @staging = grep { /^$repo_basename$/; } keys %STAGING_REPOS; - foreach my $staging_repo (@staging) { - # nothing to do if remote already exists - next if ($current_remotes{$staging_repo}); - - my $staging_repo_url = $STAGING_REPOS{$staging_repo}; - if ($protocol) { - if ($protocol ne 'http') { - $staging_repo_url =~ s,^git://gitorious\.org/qt-labs/,${url_base_for_protocol}qt/,; + if (!@staging) { + # Add origin's URL as staging's URL, since this repo has no separate staging area + unless ($current_remotes{'staging'}) { + my @configresult = qx(git remote -v); + foreach (@configresult) { + if (/origin\s+(\S+) \(fetch\)/) { + $self->exe('git', 'remote', 'add', 'staging', $1); + } } - $staging_repo_url =~ s,^git://gitorious\.org/,$url_base_for_protocol,; } - $self->exe('git', 'remote', 'add', 'staging', $staging_repo_url); + } else { + foreach my $staging_repo (@staging) { + # nothing to do if remote already exists + next if ($current_remotes{'staging'}); + + my $staging_repo_url = $STAGING_REPOS{$staging_repo}; + if ($protocol) { + if ($protocol ne 'http') { + $staging_repo_url =~ s,^git://gitorious\.org/qt-labs/,${url_base_for_protocol}qt/,; + } + $staging_repo_url =~ s,^git://gitorious\.org/,$url_base_for_protocol,; + } + $self->exe('git', 'remote', 'add', 'staging', $staging_repo_url); + } } return; From c6f334f7660a9e18393ee0fddd09298c7b19d6dc Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Wed, 1 Jun 2011 13:16:09 -0500 Subject: [PATCH 6/6] Add option --codereview-user to add Gerrit repos By providing the username used for codereviews, the script will add the proper URLs for the repos currently under Gerrit control. For repos not under Gerrit control, 'gerrit' will simply refer to the staging repo, or origin. --- init-repository | 72 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 54 insertions(+), 18 deletions(-) diff --git a/init-repository b/init-repository index 47371be0..819e042d 100755 --- a/init-repository +++ b/init-repository @@ -135,6 +135,14 @@ protocol is blocked by a firewall. Note that this only works with the external Gitorious server. +=item --codereview-username + +Adds a gerrit alias to repos under Gerrit codereview management. +This requires a username for SSH access to the codereview.qt.nokia.com +server, which will be the same username you have for the bugtracker at +bugreports.qt.nokia.com. + + =item --alternates Adds alternates for each submodule to another full qt5 checkout. This makes @@ -213,6 +221,10 @@ my %STAGING_REPOS = map { $_ => "git://gitorious.org/qt/$_-staging.git" } qw( qtsensors ); +my %GERRIT_REPOS = map { $_ => "codereview.qt.nokia.com:qt/$_.git" } qw( + qtbase +); + my $BNE_MIRROR_URL_BASE = 'git://bq-git.apac.nokia.com/qtsoftware/qt/'; @@ -252,6 +264,7 @@ sub parse_arguments %{$self} = (%{$self}, 'alternates' => "", + 'codereview-username' => "", 'detach-alternates' => 0 , 'force' => 0 , 'ignore-submodules' => 0 , @@ -265,6 +278,7 @@ sub parse_arguments GetOptionsFromArray(\@args, 'alternates=s' => \$self->{qw{ alternates }}, + 'codereview-username=s' => \$self->{qw{ codereview-username }}, 'copy-objects' => \$self->{qw{ detach-alternates }}, 'force' => \$self->{qw{ force }}, 'ignore-submodules' => \$self->{qw{ ignore-submodules }}, @@ -413,7 +427,7 @@ sub git_clone_all_submodules return; } -sub git_add_staging_remote +sub git_add_remotes { my ($self, $repo_basename) = @_; @@ -426,23 +440,17 @@ sub git_add_staging_remote $current_remotes{$line} = 1; } - my @staging = grep { /^$repo_basename$/; } keys %STAGING_REPOS; - - if (!@staging) { - # Add origin's URL as staging's URL, since this repo has no separate staging area - unless ($current_remotes{'staging'}) { - my @configresult = qx(git remote -v); - foreach (@configresult) { - if (/origin\s+(\S+) \(fetch\)/) { - $self->exe('git', 'remote', 'add', 'staging', $1); - } - } + my @gerrit = grep { /^$repo_basename$/; } keys %GERRIT_REPOS; + if (!$current_remotes{'gerrit'} && $self->{'codereview-username'}) { + foreach my $gerrit_repo (@gerrit) { + my $gerrit_repo_url = $GERRIT_REPOS{$gerrit_repo}; + $self->exe('git', 'remote', 'add', 'gerrit', $self->{'codereview-username'}."@".$gerrit_repo_url); } - } else { - foreach my $staging_repo (@staging) { - # nothing to do if remote already exists - next if ($current_remotes{'staging'}); + } + my @staging = grep { /^$repo_basename$/; } keys %STAGING_REPOS; + if (!$current_remotes{'staging'}) { + foreach my $staging_repo (@staging) { my $staging_repo_url = $STAGING_REPOS{$staging_repo}; if ($protocol) { if ($protocol ne 'http') { @@ -454,6 +462,34 @@ sub git_add_staging_remote } } + # if repo has no staging repo defined, alias it to gerrit or origin + if (!$current_remotes{'staging'} && !@staging) { + my @configresult = qx(git remote -v); + my $staging_set = 0; + foreach (@configresult) { + if (/^gerrit\s+(\S+) \(fetch\)/) { + $self->exe('git', 'remote', 'add', 'staging', $1); + $staging_set = 1; + } + } + unless($staging_set) { + foreach (@configresult) { + if (/^origin\s+(\S+) \(fetch\)/) { + $self->exe('git', 'remote', 'add', 'staging', $1); + } + } + } + } + #if repo has no gerrit repo defined, alias it to whatever staging now points to (could be origin) + if (!$current_remotes{'gerrit'} && !@gerrit) { + my @configresult = qx(git remote -v); + foreach (@configresult) { + if (/^staging\s+(\S+) \(fetch\)/) { + $self->exe('git', 'remote', 'add', 'gerrit', $1); + } + } + } + return; } @@ -515,7 +551,7 @@ sub git_clone_one_submodule $self->exe('git', 'remote', 'add', 'mirror', $mirror); } - $self->git_add_staging_remote($submodule); + $self->git_add_remotes($submodule); if ($self->{'detach-alternates'}) { $self->exe('git', 'repack', '-a'); @@ -546,7 +582,7 @@ sub run $self->git_clone_all_submodules; } - $self->git_add_staging_remote('qt5'); + $self->git_add_remotes('qt5'); return; }