Skip to content

The details behind detecting modified images

Yang Yang edited this page Mar 25, 2020 · 3 revisions

1. Diff two branches

If current branch is not master then it will diff with the latest master branch. If current branch is master then it will diff with the commit 205bbf4d430d906875a30e4a47872145ee9d06ee.

$ git diff --name-only $(git rev-parse master)

The diff command will return a list of files. The result will be filtered and aggregated into a list of ImageBundle objects which represent some images in images folder like bitcoind/0.19.1, utils, etc.

2. Iterate branch history to get modified images for each commit

The second step is to iterate the history of current branch and find modified images for each commit in the history.

master -> c1 -> c2 -> c3 -> c4

c4: img1
c3: img1, img2
c2: 
c1: img2, img3

3. Get unmodified history for each image

img1: []
img2: [c4]
img3: [c2, c3, c4]

4. Use unmodifed history to determine which image needs to be built

Say the cloud img3 has a label "com.exchangeunion.image.revision" whose value is c3 and current Git HEAD is c4, we will NOT build img3 because the cloud version has no differences with the HEAD according to the unmodified history.

We use this technique to detect the real modifed images to build on Travis.