Skip to content

Commit ebecbeb

Browse files
bhourahinearadi
andcommitted
Checks consistency of cmake and submodule repo
Add flag for consistency check, as the github action was failing on the script (which had no problems locally). Two of the submodules were pointing to a fork or a non-existing fork (github.com/dftbplus/chimes_calculator gives a 404). Also change to the headless github repo URLs for various projects without the .git Changes from review Co-authored-by: Bálint Aradi <[email protected]>
1 parent 32662c9 commit ebecbeb

File tree

3 files changed

+40
-13
lines changed

3 files changed

+40
-13
lines changed

.gitmodules

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@
1818
url = https://github.com/tblite/tblite.git
1919
[submodule "external/mctc-lib/origin"]
2020
path = external/mctc-lib/origin
21-
url = https://github.com/grimme-lab/mctc-lib
21+
url = https://github.com/grimme-lab/mctc-lib.git
2222
[submodule "external/s-dftd3/origin"]
2323
path = external/s-dftd3/origin
24-
url = https://github.com/dftd3/simple-dftd3
24+
url = https://github.com/dftd3/simple-dftd3.git
2525
[submodule "external/dftd4/origin"]
2626
path = external/dftd4/origin
27-
url = https://github.com/dftd4/dftd4
27+
url = https://github.com/dftd4/dftd4.git
2828
[submodule "external/multicharge/origin"]
2929
path = external/multicharge/origin
30-
url = https://github.com/grimme-lab/multicharge
30+
url = https://github.com/grimme-lab/multicharge.git
3131
[submodule "external/mstore/origin"]
3232
path = external/mstore/origin
33-
url = https://github.com/grimme-lab/mstore
33+
url = https://github.com/grimme-lab/mstore.git
3434
[submodule "external/toml-f/origin"]
3535
path = external/toml-f/origin
36-
url = https://github.com/toml-f/toml-f
36+
url = https://github.com/toml-f/toml-f.git
3737
[submodule "external/chimes/origin"]
3838
path = external/chimes/origin
39-
url = https://github.com/rk-lindsey/chimes_calculator
39+
url = https://github.com/rk-lindsey/chimes_calculator.git

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ if(WITH_TBLITE OR WITH_SDFTD3)
250250
#list(APPEND PKG_CONFIG_REQUIRES toml-f)
251251
endif()
252252

253-
set(S_DFTD3_GIT_REPOSITORY "https://github.com/awvwgk/simple-dftd3.git")
253+
set(S_DFTD3_GIT_REPOSITORY "https://github.com/dftd3/simple-dftd3.git")
254254
set(S_DFTD3_GIT_TAG "5ee8c4d71414bf54db0b680ee3c532215847e0f9") # do not change manually!
255255
dftbp_config_hybrid_dependency(s-dftd3 s-dftd3::s-dftd3 "${HYBRID_CONFIG_METHODS}" "QUIET"
256256
external/s-dftd3 "${exclude}" "${S_DFTD3_GIT_REPOSITORY}" "${S_DFTD3_GIT_TAG}")
@@ -285,7 +285,7 @@ endif()
285285

286286
# ChIMES currently can only be integrated as a submodule
287287
if(WITH_CHIMES)
288-
set(CHIMES_GIT_REPOSITORY "https://github.com/dftbplus/chimes_calculator.git")
288+
set(CHIMES_GIT_REPOSITORY "https://github.com/rk-lindsey/chimes_calculator.git")
289289
set(CHIMES_GIT_TAG "7ca7d397197ac8ca4b1fc54ee12164911a6254b7") # do not change manually!
290290
dftbp_config_hybrid_dependency(ChimesCalc ChimesCalc::ChimesCalc_Fortran
291291
"${HYBRID_CONFIG_METHODS}" "QUIET"

utils/test/check_submodule_commits

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
"""Checks the submodule commit IDs in integration CMake files."""
44

5+
import argparse
6+
import configparser
57
import os
6-
import subprocess
78
import re
8-
import argparse
9+
import subprocess
910
import sys
1011

1112
_DESCRIPTION = """
@@ -33,23 +34,32 @@ def main():
3334
result = subprocess.run(["git", "submodule", "status"],
3435
stdout=subprocess.PIPE, check=True)
3536
output = result.stdout.decode('ascii')
37+
if args.check:
38+
gitconfig = configparser.ConfigParser()
39+
gitconfig.read('.git/config')
3640
allsync = True
3741
with open("CMakeLists.txt", "r") as fp:
3842
origcontent = fp.read()
3943
content = origcontent
4044
for match in _PAT_SUBMOD_COMMIT.finditer(output):
4145
commit, submodule = match.groups()
46+
if args.check:
47+
locale = ('submodule "external/%s/origin"' % submodule)
48+
active = gitconfig.get(locale, 'active')
49+
if active == 'true':
50+
url = gitconfig.get(locale, 'url')
51+
_check_submodule_url(content, submodule, url)
4252
newcontent, nn = _replace_submodule_commit(content, submodule, commit)
4353
if nn < 1:
4454
print("! Commit for submodule {} was NOT FOUND".format(submodule))
4555
allsync = False
4656
continue
4757
sync = (newcontent == content)
4858
if sync:
49-
print("+ Commit for submodule {} matches.".format(submodule))
59+
print("+ Commit ID for submodule {} matches.".format(submodule))
5060
elif args.update:
5161
content = newcontent
52-
print("* Commit for submodule {} had been updated."\
62+
print("* Commit for submodule {} has been updated."\
5363
.format(submodule))
5464
else:
5565
print("! Commit for submodule {} DOES NOT MATCH!".format(submodule))
@@ -66,6 +76,8 @@ def _parse_arguments():
6676
parser = argparse.ArgumentParser(description=_DESCRIPTION)
6777
msg = "Whether the commits should be updated in the CMakeLists.txt files"
6878
parser.add_argument("-u", "--update", action='store_true', help=msg)
79+
msg = "Check consistency between CMakeLists.txt and submodules"
80+
parser.add_argument("-c", "--check", action='store_true', help=msg)
6981
return parser.parse_args()
7082

7183

@@ -82,5 +94,20 @@ def _replace_submodule_commit(content, submodule, commit):
8294
return newcontent, nsubs
8395

8496

97+
def _check_submodule_url(content, submodule, url):
98+
"""Checks consistency of the submodule url in the CMakeLists.txt file"""
99+
submodule_normed = submodule.upper()
100+
submodule_normed = re.sub(
101+
_PAT_SPECIAL_CHAR, _SPECIAL_CHAR_REPLACEMENT, submodule_normed)
102+
match = re.findall(
103+
r"set\({}_GIT_REPOSITORY \"({})(\.git)?\"\)".format(submodule_normed, url),
104+
content)
105+
if (len(match) == 0):
106+
print('** {} : mismatch between .git/config and CMakeLists.txt'.format(submodule))
107+
else:
108+
if (match[0][1] == '.git'):
109+
print("* {} : bare vs non-bare repository address in CMakeLists.txt and .git/config".format(submodule))
110+
111+
85112
if __name__ == '__main__':
86113
main()

0 commit comments

Comments
 (0)