3

I'm using CircleCI to build an Android Github private project. Builds work fine but the commit history of origin/master on the container is different from what I get on my local machine.

I did a diff b/w output of git rev-list origin/master on my local machine and container and found quite a few differences - i.e. there are commits missing in the repo on the container.

I tried cloning the project from Github to my local machine and it showed me the same git commit history (correct commit count), is CircleCI doing something different?

9
  • The output of git rev-list origin/master does not matter. If the revision built by CircleCI is the right one, it's just okay. CircleCI could have a shallow-clone or a branch-specific fetch that does not touch its origin/master.
    – ElpieKay
    Commented May 19, 2017 at 7:06
  • It matters for me because I'm using the output of git rev-list --first-parent --count origin/master as my app's versionCode actually! Also I'm sure that CircleCI is building on the master branch.
    – Vibin
    Commented May 19, 2017 at 7:12
  • More info: I tried git log --reverse on the container, and that is not the initial commit.
    – Vibin
    Commented May 19, 2017 at 7:13
  • 1
    Then it's alright. origin/master records the status of master in the remote repository during last sync. It's not always the current head of master in the remote repository. It's quite normal that origin/master in your local maschine is different from the one in the container because they could sync with the remote repository at different moments.
    – ElpieKay
    Commented May 19, 2017 at 8:03
  • 1
    1. Your local machine syncs. The remote repository is updated by someone. The container syncs. It results in that the local machine has fewer commits than the container. 2. Your local machine makes a full clone but the container makes a shallow-clone, with --depth=1 for example. Then the local machine has much more commits than the container. These are the possible cases that come to my mind.
    – ElpieKay
    Commented May 19, 2017 at 8:13

2 Answers 2

5

CircleCI 1.0 does a shallow clone, which is causing what you see.

Before cloning a repo, CircleCI checks to see if a "source cache" is available. If so, it uses it to recreate .git/. Then, on CircleCI 1.0, a shallow clone is done. On CircleCI 2.0 (in beta), a standard clone is done. Then, work is done to get to the correct commit/tag.

If you want to convert the repository on CircleCI 1.0 to an unshallow one, the following command does the trick:

"[[ ! -s \"$(git rev-parse --git-dir)/shallow\" ]] || git fetch --unshallow"

On 1.0, the source cache is saved after the dependencies phase so I'd suggest not doing this after that phase so that the cache can be kept efficiently. For 2.0, it's saved when the save_cache step is run.

-Ricardo N Feliciano
Developer Evangelist, CircleCI

1
  • 1
    Thanks for the confirmation and the extra information!
    – Vibin
    Commented May 26, 2017 at 13:10
1

As @ElpieKay mentioned in the comments, this has to do with CircleCI shallow cloning the repo. Refer to https://github.com/prontolabs/pronto/issues/103 for circle.yml config for full cloning. For example, I did:

checkout:
    post:
        - "[[ ! -s \"$(git rev-parse --git-dir)/shallow\" ]] || git fetch --unshallow"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.