xorpaul/g10k

Changing a remote's Git URL doesn't update the cache

ekohl opened this issue · 5 comments

ekohl commented

Consider the following config

cachedir: '/var/cache/g10k'

sources:
  control:
    remote: 'https://example.com/my-git-repo'
    basedir: '/var/lib/g10k/environments'

Then I run g10k. This does what I want and we can see that:

# git -C /var/cache/g10k/environments/control.git remote -v
origin	https://example.com/my-git-repo (fetch)
origin	https://example.com/my-git-repo (push)

However, now my git repo URL changes:

cachedir: '/var/cache/g10k'

sources:
  control:
    remote: 'https://git.example.com/my-git-repo'
    basedir: '/var/lib/g10k/environments'

Again, I run g10k. This exits successfully. However, the code isn't updated. This is because the cache still points to the same remote.

# git -C /var/cache/g10k/environments/control.git remote -v
origin	https://example.com/my-git-repo (fetch)
origin	https://example.com/my-git-repo (push)

Removing control.git and running g10k again does result in a correct git remote.

Hmm, can you think of a better solution than g10k always comparing the git remote at the beginning?

ekohl commented

The other is to always set it. I haven't looked at the code, but I think git remote set-url is a pretty cheap operation. AFAIK it's only changing .git/config.