lib/octofacts_updater/service/github.rb
# Private: Ensure branch exists. This will use octokit to create the branch on GitHub if the branch
# does not already exist.
Ensure branch exists. This will use octokit to create the branch on GitHub if the branch
does not already exist.
Ensure branch exists . This will use octokit to create the branch on GitHub if the branch does not already exist .
def ensure_branch_exists
        @ensure_branch_exists ||= begin
          created = false
          begin
            if octokit.branch(repository, branch)
              verbose("Branch #{branch} already exists in #{repository}.")
              created = true
            end
          rescue Octokit::NotFound
          end
          unless created
            base_sha = octokit.branch(repository, default_branch)[:commit][:sha]
            octokit.create_ref(repository, "heads/#{branch}", base_sha)
            verbose("Created branch #{branch} based on #{default_branch} #{base_sha}.")
          end
          true
        end
      end
def ensure_branch_exists @ensure_branch_exists ||= begin created = false begin if octokit . branch ( repository , branch ) verbose ( "Branch #{branch} already exists in #{repository}." ) created = true end rescue Octokit :: NotFound end unless created base_sha = octokit . branch ( repository , default_branch ) [ :commit ] [ :sha ] octokit . create_ref ( repository , "heads/#{branch}" , base_sha ) verbose ( "Created branch #{branch} based on #{default_branch} #{base_sha}." ) end true end end
Private: Ensure branch exists.
Private : Ensure branch exists .
# Fine, we'll create it