ndemoreau
ndemoreau

Reputation: 3869

git one local branch synchronizing with multiple remote branches: how to?

I have one application that I sold to multiple clients. Each client has his own dedicated application (on Heroku).

The applications of these customers only differ by 3 config files: database.yml, aws.yml and corporate.rb

Locally, I have one master branch and as many other local branches as I have customers. I need these local branches to store the 3 config files of each customer. Every time I make a change on the master, I merge it with every customer branches and push them one by one to Heroku.

This is quite heavy...

Following suggestion of this post: pull/push from multiple remote locations, I created one remote grouped branch and hacked my config file so that this branch is associated to multiple urls.

The problem is that when I try to push it, It refuses to do it because the remotes are not correctly synchronized. If I force the push, it overwrites my config files, which is not a solution either.

I tried to include these config files in .gitignore, but it keeps pushing them.

Any idea to solve this issue? Thanks!!!

Upvotes: 1

Views: 222

Answers (2)

ndemoreau
ndemoreau

Reputation: 3869

I solved the issue by using Heroku's environment variables. Actually, I don't have to set any variable to use them. I just use the APP_NAME variable and set my config for each app in an initializer file:

# Custom values

  case ENV['APP_NAME']
  when 'pgp'
    CORPORATE_NAME = 'PGP Development'
    S3_BUCKET = 'pgpdevelopment'
  when 'anchor'
    CORPORATE_NAME = 'Anchor Group'
    S3_BUCKET = 'anchorgroup'
  when 'corionl'
    CORPORATE_NAME = 'Corio NL'
  when 'masterproj'
    CORPORATE_NAME = 'Corporate Demo'
  when 'adg'
    CORPORATE_NAME = 'ADG'
  end

#Default values

  CORPORATE_NAME ||= ENV['APP_NAME']
  DEPARTMENT_SELECTION ||= false
  GEOSCOPE_SELECTION ||= false
  GEOSCOPE_DEFAULT ||= 'world'
  DEPARTMENT_DEFAULT ||= 'all'
  S3_BUCKET ||= ENV['APP_NAME']

  S3_CREDENTIALS = {
  :access_key_id => my_key_id,
  :secret_access_key => my_access_key
  }
  if Rails.env == "production"
       S3_CREDENTIALS[:bucket] = S3_BUCKET
  else
       S3_CREDENTIALS[:bucket] = "#{S3_BUCKET}_dev"
  end

Thx for putting me on the right track!

Upvotes: 1

Adam Dymitruk
Adam Dymitruk

Reputation: 129664

I would not version control customer specific artifacts in your repository. Do a transform elsewhere and then push from there to heroku. You need an "admin" repo.

Upvotes: 0

Related Questions