Repository: rails/rails
File: railties/lib/rails/generators/app_base.rb (Ruby)

Code before:

      def add_bundler_platforms
        if bundle_install? && !jruby?
          # The vast majority of Rails apps will be deployed on `x86_64-linux`.
          bundle_command("lock --add-platform=x86_64-linux")

          # Users that develop on M1 mac may use docker and would need `aarch64-linux` as well.
          bundle_command("lock --add-platform=aarch64-linux") if RUBY_PLATFORM.start_with?("arm64")
        end
      end

      def jruby?
        defined?(JRUBY_VERSION)
      end

      def empty_directory_with_keep_file(destination, config = {})
        empty_directory(destination, config)
        keep_file(destination)
      end

      def keep_file(destination)
        create_file("#{destination}/.keep") if keeps?
      end

      def user_default_branch
        @user_default_branch ||= `git config init.defaultbranch`.strip
      end

      def git_init_command
        return "git init" if user_default_branch.present?

        git_version = `git --version`[/\d+\.\d+\.\d+/]

        if Gem::Version.new(git_version) >= Gem::Version.new("2.28.0")
          "git init -b main"
        else
          "git init && git symbolic-ref HEAD refs/heads/main"
        end
      end

      def edge_branch
        self.class.edge_branch
      end

      def dockerfile_chown_directories
        directories = %w(log tmp)

        directories << "storage" unless skip_storage?
        directories << "db" unless skip_active_record?

        directories.sort

Review comment (bug):
I'm not sure how frequent this is, but if a user doesn't have git installed and runs `rails new my_app --skip-git` this will now crash the process.

Code after:
        commands = "solid_cache:install solid_queue:install"
        commands += " solid_cable:install" unless skip_action_cable?

        rails_command commands
      end

      def add_bundler_platforms
        if bundle_install? && !jruby?
          # The vast majority of Rails apps will be deployed on `x86_64-linux`.
          bundle_command("lock --add-platform=x86_64-linux")

          # Users that develop on M1 mac may use docker and would need `aarch64-linux` as well.
          bundle_command("lock --add-platform=aarch64-linux") if RUBY_PLATFORM.start_with?("arm64")
        end
      end

      def jruby?
        defined?(JRUBY_VERSION)
      end

      def empty_directory_with_keep_file(destination, config = {})
        empty_directory(destination, config)
        keep_file(destination)
      end

      def keep_file(destination)
        create_file("#{destination}/.keep") if keeps?
      end

      def user_default_branch
        @user_default_branch ||= capture_command("git config init.defaultbranch").strip.presence || "main"
      end

      def git_init_command
        if capture_command("git config init.defaultbranch").present?
          return "git init"
        end

        git_version = `git --version`[/\d+\.\d+\.\d+/]

        if Gem::Version.new(git_version) >= Gem::Version.new("2.28.0")
          "git init -b main"
        else
          "git init && git symbolic-ref HEAD refs/heads/main"
        end
      end

      def edge_branch
        self.class.edge_branch
      end