It seems that when you specify source-type: git and source: . to use the git source from the local directory, that snapcraft never notices a change to the source and will re-used the cached source. This results in a re-built snap that has not integrated local code changes, which is very surprising.
I would make a local change to the bin/sstream-query file, re-run snapcraft and then the change would not be included. The same is true if I actually make a git commit with the change. It seems that the PULL stage is presumed clean and is not re-run as the override-pull steps to set the version from the git hash also don't seem to get re-run, even if I've made an actual commit that changes it's output. Additionally, if you make a change to the override-pull script to force it to re-run the step then it will pickup both committed and non-committed changes in that case. So it doesn't seem to be a case of it comparing the git hash or ignore local changes.
If you change the source tree to use source-type: local this doesn't happen, and changing a file (whether committed or not) results in the pull stage re-running and the source not being cached.
Ideally this behaviour would be fixed, or possibly we should disallow this to stop people shooting themselves in the foot.
Bug Description
It seems that when you specify
source-type: git
andsource: .
to use the git source from the local directory, that snapcraft never notices a change to the source and will re-used the cached source. This results in a re-built snap that has not integrated local code changes, which is very surprising.I ran into this while working on the Simplestreams Snap (https://git.launchpad.net/simplestreams) which currently does this.
I would make a local change to the bin/sstream-query file, re-run
snapcraft
and then the change would not be included. The same is true if I actually make a git commit with the change. It seems that the PULL stage is presumed clean and is not re-run as theoverride-pull
steps to set the version from the git hash also don't seem to get re-run, even if I've made an actual commit that changes it's output. Additionally, if you make a change to the override-pull script to force it to re-run the step then it will pickup both committed and non-committed changes in that case. So it doesn't seem to be a case of it comparing the git hash or ignore local changes.If you change the source tree to use
source-type: local
this doesn't happen, and changing a file (whether committed or not) results in the pull stage re-running and the source not being cached.Ideally this behaviour would be fixed, or possibly we should disallow this to stop people shooting themselves in the foot.
To Reproduce
git clone https://git.launchpad.net/simplestreams
snapcraft
Modify bin/sstream-query
snap install --dangerous ./simplestreams_*.snap
diff /snap/simplestreams/current/bin/sstream-query ./bin/sstream-query
Environment
Snapcraft: 8.2.12 (12024) tracking latest/stable Ubuntu 22.04 Build Provider: LXD
snapcraft.yaml
Relevant log output
Additional context
No response