Checkout: Get rid of node and typescript

Created on 23 Dec 2019  路  4Comments  路  Source: actions/checkout

Why not just git clone https://github.com/$GITHUB_REPOSITORY .? As I understand, the script does the same, though it is inefficient.

question

All 4 comments

The workflow auth token is available and you can script git clone if that works better for your scenario.

The checkout action is a convenience and by default fetches only the single sha/commit that triggered the workflow. Sometimes a full clone is faster, but often (lots of history) single commit is faster.

Isn't --depth=1 enough to get a single commit?

Depth applies to each ref in the refspec.

Another problem is to formulate the correct refspec (to fetch a single ref only). Before git wire protocol v2 (wire protocol v0 is the default), it will fail if you try to fetch a single commit that is not the tip of the branch.

So for example for pull requests, the SHA must be fetched and not the ref. If the ref were fetched, then it could slide to a different SHA before the job starts (race condition). In order to reliably fetch by SHA, git wire protocol v2 must be used.

Also note, this action solves other common problems such as running git clean, and falling back to REST API if git isn't in the PATH.

Another common problem is collisions on ref path. The action creates local refs (many users desire) instead of deatched HEAD. However that can be problematic when branch foo is created, later deleted, and foo/bar created. The action cleans up local refs to avoid the collision.

If scripting git yourself, those types of issues would need to be handled or avoided.

Thank you for the detailed explaination.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jcharnley picture jcharnley  路  4Comments

gitfool picture gitfool  路  3Comments

pdcmoreira picture pdcmoreira  路  3Comments

bk2204 picture bk2204  路  3Comments

tsal picture tsal  路  6Comments