g10k icon indicating copy to clipboard operation
g10k copied to clipboard

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

Open ekohl opened this issue 4 years ago • 4 comments

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.

ekohl avatar Oct 01 '21 11:10 ekohl

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

xorpaul avatar Oct 06 '21 11:10 xorpaul

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.

ekohl avatar Oct 06 '21 12:10 ekohl

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

xorpaul avatar May 30 '22 15:05 xorpaul

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

xorpaul avatar May 30 '22 15:05 xorpaul

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

xorpaul avatar Nov 30 '22 14:11 xorpaul