xorpaul / g10k

my r10k fork in Go
Apache License 2.0
125 stars 50 forks source link

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

Closed ekohl closed 1 year ago

ekohl commented 2 years ago

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.

xorpaul commented 2 years ago

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

ekohl commented 2 years ago

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.

xorpaul commented 2 years ago

Fixed in https://github.com/xorpaul/g10k/releases/tag/v0.9.2

xorpaul commented 2 years ago

https://github.com/xorpaul/g10k/pull/196/commits/098d9e377748f691fd7b3b525b3a1abc500cf46f

xorpaul commented 1 year ago

Fixed in https://github.com/xorpaul/g10k/releases/tag/v0.9.2