1    maybe(
2        new_git_repository,
3        name = "{{ crate_repository(name = crate.name, version = crate.version) }}",
4    {%- for type, commitish in attrs.commitish %}
5    {%- if type in ["Rev"] %}
6        commit = "{{ commitish }}",
7    {%- elif type in ["Tag"] %}
8        tag = "{{ commitish }}",
9    {%- elif type in ["Branch"] %}
10        branch = "{{ commitish }}",
11    {%- else %}
12        {{ throw(message= "Unexpected git commitish '" ~ type ~ "' for '" ~ crate.name ~ "'") }}
13    {%- endif %}
14    {%- endfor %}
15        init_submodules = True,
16    {%- if attrs | get(key="patch_args", default=Null) %}
17        patch_args = [
18    {%- for arg in attrs.patch_args %}
19            "{{ arg }}",
20    {%- endfor %}
21        ],
22    {%- endif %}
23    {%- if attrs | get(key="patch_tool", default=Null) %}
24        patch_tool = "{{ attrs.patch_tool }}",
25    {%- endif %}
26    {%- if attrs | get(key="patches", default=Null) %}
27        patches = [
28    {%- for patch in attrs.patches %}
29            "{{ patch }}",
30    {%- endfor %}
31        ],
32    {%- endif %}
33    {%- if attrs | get(key="shallow_since", default=Null) %}
34        shallow_since = "{{ attrs.shallow_since }}",
35    {%- endif %}
36        remote = "{{ attrs.remote }}",
37        build_file = Label("{{ crate_build_file(name = crate.name, version = crate.version)}}"),
38    {%- if attrs.strip_prefix %}
39        strip_prefix = "{{ attrs.strip_prefix }}",
40    {%- endif %}
41    )
42