File tree Expand file tree Collapse file tree 4 files changed +192
-0
lines changed
Expand file tree Collapse file tree 4 files changed +192
-0
lines changed Original file line number Diff line number Diff line change 1+ commit 3be5a1951f352b20d1eb404d01400d565c1b37fd
2+ Author: Alexeev Bronislav <alexeev.dev@mail.ru >
3+ Date: Mon Aug 4 06:24:33 2025 +0700
4+
5+ update readme
6+
17commit eb19f11f0ec57e22140ba76cc4576715080ec3c0
28Author: Alexeev Bronislav <alexeev.dev@mail.ru >
39Date: Mon Aug 4 06:23:37 2025 +0700
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+ import os
3+ import re
4+
5+
6+ class GitVersion ():
7+ def __init__ (self ):
8+ self ._default_version = '0.1.0'
9+ os .chdir (os .path .dirname (os .path .realpath (__file__ )))
10+
11+ @property
12+ def tag (self ):
13+ stream = os .popen ("git describe --match v[0-9]* --abbrev=0 --tags" )
14+ return stream .read ().strip ()
15+
16+ @property
17+ def version (self ):
18+ version = f"{ self .tag [1 :]} .{ self .build } "
19+
20+ if version == '.' :
21+ return self ._default_version
22+
23+ return version
24+
25+ @property
26+ def default_branch (self ):
27+ stream = os .popen ('git config --get init.defaultBranch' )
28+ result = stream .read ().strip ()
29+
30+ if not result :
31+ result = "main"
32+
33+ return result
34+
35+ @property
36+ def build (self ):
37+ stream = os .popen ("git rev-list {}.. --count" .format (self .tag ))
38+ return stream .read ().strip ()
39+
40+ @property
41+ def branch (self ):
42+ stream = os .popen ('git branch --show-current' )
43+ return stream .read ().strip ()
44+
45+ @property
46+ def full (self ):
47+ return f"{ self .version } -{ self .branch } "
48+
49+ @property
50+ def standard (self ):
51+ standard = f'{ self .version } -{ self .branch } '
52+ if self .branch == self .default_branch or re .match ("release/.*" , self .branch ):
53+ standard = f'{ self .version } '
54+ return standard
55+
56+ @property
57+ def commit (self ):
58+ stream = os .popen ("git rev-parse HEAD" )
59+ return stream .read ().strip ()
60+
61+ @property
62+ def commit_hash (self ):
63+ stream = os .popen ("git rev-parse --short HEAD" )
64+ return stream .read ().strip ()
65+
66+ def __str__ (self ):
67+ return f'''
68+ Tag: { self .tag }
69+ Version: { self .version }
70+ Full: { self .full }
71+ Branch: { self .branch }
72+ Build: { self .build }
73+ Standard: { self .standard }
74+ Commit: { self .commit }
75+
76+ SLeaf-LLVM { self .full } { self .commit_hash }
77+ '''
78+
79+
80+ if __name__ == '__main__' :
81+ git_version = GitVersion ()
82+ print (git_version )
Original file line number Diff line number Diff line change 1+ import os
2+ from pathlib import Path
3+ import sys
4+
5+
6+ def create_hpp_for_cpp_file (cpp_path ):
7+ hpp_path = cpp_path .with_suffix ('.hpp' )
8+ if not hpp_path .exists ():
9+ hpp_path .touch ()
10+
11+
12+ def process_directory (source_dir ):
13+ for root , _ , files in os .walk (source_dir ):
14+ for file in files :
15+ if file .endswith (('.cpp' , '.cxx' )):
16+ cpp_path = Path (root ) / file
17+ create_hpp_for_cpp_file (cpp_path )
18+
19+
20+ if __name__ == '__main__' :
21+ source_directory = Path (sys .argv [1 ])
22+ process_directory (source_directory )
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+ import os
3+ import re
4+
5+
6+ class GitVersion ():
7+ def __init__ (self ):
8+ self ._default_version = '0.1.0'
9+ os .chdir (os .path .dirname (os .path .realpath (__file__ )))
10+
11+ @property
12+ def tag (self ):
13+ stream = os .popen ("git describe --match v[0-9]* --abbrev=0 --tags" )
14+ return stream .read ().strip ()
15+
16+ @property
17+ def version (self ):
18+ version = f"{ self .tag [1 :]} .{ self .build } "
19+
20+ if version == '.' :
21+ return self ._default_version
22+
23+ return version
24+
25+ @property
26+ def default_branch (self ):
27+ stream = os .popen ('git config --get init.defaultBranch' )
28+ result = stream .read ().strip ()
29+
30+ if not result :
31+ result = "main"
32+
33+ return result
34+
35+ @property
36+ def build (self ):
37+ stream = os .popen ("git rev-list {}.. --count" .format (self .tag ))
38+ return stream .read ().strip ()
39+
40+ @property
41+ def branch (self ):
42+ stream = os .popen ('git branch --show-current' )
43+ return stream .read ().strip ()
44+
45+ @property
46+ def full (self ):
47+ return f"{ self .version } -{ self .branch } "
48+
49+ @property
50+ def standard (self ):
51+ standard = f'{ self .version } -{ self .branch } '
52+ if self .branch == self .default_branch or re .match ("release/.*" , self .branch ):
53+ standard = f'{ self .version } '
54+ return standard
55+
56+ @property
57+ def commit (self ):
58+ stream = os .popen ("git rev-parse HEAD" )
59+ return stream .read ().strip ()
60+
61+ @property
62+ def commit_hash (self ):
63+ stream = os .popen ("git rev-parse --short HEAD" )
64+ return stream .read ().strip ()
65+
66+ def __str__ (self ):
67+ return f'''
68+ Tag: { self .tag }
69+ Version: { self .version }
70+ Full: { self .full }
71+ Branch: { self .branch }
72+ Build: { self .build }
73+ Standard: { self .standard }
74+ Commit: { self .commit }
75+
76+ Domkrat3D { self .full } { self .commit_hash }
77+ '''
78+
79+
80+ if __name__ == '__main__' :
81+ git_version = GitVersion ()
82+ print (git_version )
You can’t perform that action at this time.
0 commit comments