0 votes
1 view
in Devops and Agile by (20k points)

I'm sort of new to bundler and the files it generates. I have a copy of a git repo from GitHub that is being contributed to by many people so I was surprised to find that bundler created a file that didn't exist in the repo and wasn't in the .gitignore list.

Since I have forked it, I know adding it to the repo won't break anything for the main repo, but if I do a pull request, will it cause a problem?

Should Gemfile.lock be included in the repository?

1 Answer

0 votes
by (28.4k points)

To check in Gemfile.lock with the default set of gems, at the same time to ignore changes that you have made on your machine run the following command:

$ git update-index --assume-unchanged Gemfile.lock

To reverse:

$ git update-index --no-assume-unchanged Gemfile.lock

You can use the following code in your Gemfile which will load the appropriate database adapter gem, based on your database.yml.

# This code will load the database adapter gem based on config/database.yml (Default: mysql2)

db_gems = {"mysql2"     => ["mysql2", ">= 0.2.6"],

           "postgresql" => ["pg",     ">= 0.9.0"],

           "sqlite3"    => ["sqlite3"]}

adapter = if File.exists?(db_config = File.join(File.dirname(__FILE__),"config","database.yml"))

  db = YAML.load_file(db_config)

  # Fetch the first configured adapter from config/database.yml

  (db["production"] || db["development"] || db["test"])["adapter"]

else

  "mysql2"

end

gem *db_gems[adapter]

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...