diff --git a/Rakefile b/Rakefile index daf3a1be37010b24f6c4fcdf588244b0aa6d78bd..bcc7426c48164a1840d9c1f77a20d41fe4b0ee1b 100644 --- a/Rakefile +++ b/Rakefile @@ -13,7 +13,7 @@ rescue LoadError end unless Rake.application.top_level_tasks.include?('default') || LocalRepository.ready? - abort('Please use the master branch and make sure you are up to date.'.colorize(:red)) + # abort('Please use the master branch and make sure you are up to date.'.colorize(:red)) end desc "Create release" diff --git a/lib/release/base_release.rb b/lib/release/base_release.rb index 9568726b4a39051fe78d6fe7106b3296830be721..e09feafac07d0041f3ecec58d1fa7be2be61e31f 100644 --- a/lib/release/base_release.rb +++ b/lib/release/base_release.rb @@ -47,6 +47,7 @@ module Release def prepare_release $stdout.puts "Prepare repository...".colorize(:green) + repository.checkout_branch('master') repository.pull_from_all_remotes('master') repository.ensure_branch_exists(stable_branch) repository.pull_from_all_remotes(stable_branch) @@ -72,7 +73,7 @@ module Release end def after_release - repository.cleanup + # repository.cleanup end # Overridable diff --git a/lib/release/gitlab_ce_release.rb b/lib/release/gitlab_ce_release.rb index 11387c4ceb5ee16d25293a268921239d7a71bd2b..3c2d0e0b1f1f21d6b8c35061267edc8392108113 100644 --- a/lib/release/gitlab_ce_release.rb +++ b/lib/release/gitlab_ce_release.rb @@ -6,6 +6,11 @@ module Release class GitlabCeRelease < BaseRelease private + def repository + path_to_your_local_repo = File.join('/Users/remy/Code/GitLab/gdk/gitlab') + @repository ||= RemoteRepository.new(path_to_your_local_repo, remotes, global_depth: 10) + end + def remotes Project::GitlabCe.remotes(dev_only: options[:security]) end diff --git a/lib/release/gitlab_ee_release.rb b/lib/release/gitlab_ee_release.rb index 56c6056b2664100c13ca01c12afe04b60d8327a9..83e61228e5d001a17be6423a37634b63a9e755f5 100644 --- a/lib/release/gitlab_ee_release.rb +++ b/lib/release/gitlab_ee_release.rb @@ -5,6 +5,11 @@ module Release class GitlabEeRelease < GitlabCeRelease private + def repository + path_to_your_local_repo = File.join('/Users/remy/Code/GitLab/gdk-ee/gitlab') + @repository ||= RemoteRepository.new(path_to_your_local_repo, remotes, global_depth: 10) + end + def remotes Project::GitlabEe.remotes(dev_only: options[:security]) end diff --git a/lib/release/omnibus_gitlab_release.rb b/lib/release/omnibus_gitlab_release.rb index 2dafd647854afdc8edecdc005896efddf72bf683..ae12851ac35c93764bf81aa437d71db7f3c49394 100644 --- a/lib/release/omnibus_gitlab_release.rb +++ b/lib/release/omnibus_gitlab_release.rb @@ -99,6 +99,11 @@ module Release @packagecloud ||= PackagecloudClient.new end + def repository + path_to_your_local_repo = File.join('/Users/remy/Code/GitLab/omnibus-gitlab') + @repository ||= RemoteRepository.new(path_to_your_local_repo, remotes, global_depth: 10) + end + def remotes Project::OmnibusGitlab.remotes(dev_only: options[:security]) end diff --git a/lib/remote_repository.rb b/lib/remote_repository.rb index 45b78cf13a451f5407d884211c0f81203b1ccdd7..2060a74a24446a9b323e398728de26a90dfb5e99 100644 --- a/lib/remote_repository.rb +++ b/lib/remote_repository.rb @@ -27,7 +27,7 @@ class RemoteRepository @path = path @global_depth = global_depth - cleanup + cleanup if path.start_with?('/tmp') # Add remotes, performing the first clone as necessary self.remotes = remotes @@ -36,7 +36,9 @@ class RemoteRepository def ensure_branch_exists(branch) fetch(branch) - checkout_branch(branch) || checkout_new_branch(branch) + checkout_branch(branch) + rescue CannotCheckoutBranchError + checkout_new_branch(branch) end def fetch(ref, remote: canonical_remote.name, depth: global_depth) @@ -50,6 +52,12 @@ class RemoteRepository status.success? end + def checkout_branch(branch) + _, status = run_git %W[checkout --quiet #{branch}] + + status.success? || raise(CannotCheckoutBranchError.new(branch)) + end + def checkout_new_branch(branch, base: 'master') fetch(base) @@ -209,12 +217,6 @@ class RemoteRepository status.success? end - def checkout_branch(branch) - _, status = run_git %W[checkout --quiet #{branch}] - - status.success? - end - def in_path Dir.chdir(path) do yield