semtag 0.1.3__py3-none-any.whl → 0.2.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {semtag-0.1.3.dist-info → semtag-0.2.1.dist-info}/METADATA +17 -11
- semtag-0.2.1.dist-info/RECORD +8 -0
- semtag.py +38 -36
- semtag-0.1.3.dist-info/RECORD +0 -8
- {semtag-0.1.3.dist-info → semtag-0.2.1.dist-info}/WHEEL +0 -0
- {semtag-0.1.3.dist-info → semtag-0.2.1.dist-info}/entry_points.txt +0 -0
- {semtag-0.1.3.dist-info → semtag-0.2.1.dist-info}/licenses/LICENSE +0 -0
- {semtag-0.1.3.dist-info → semtag-0.2.1.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: semtag
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: A tool for managing semantic version tags in git repositories
|
|
5
5
|
Author-email: Mateusz Mikrut <mateusz.mikrut@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -25,7 +25,7 @@ Dynamic: license-file
|
|
|
25
25
|
|
|
26
26
|
# Semantic Version GIT Tagger
|
|
27
27
|
|
|
28
|
-
A pretty trivial python script to
|
|
28
|
+
A pretty trivial python script to easily manage git tags with semantic versioning (semver.org)
|
|
29
29
|
|
|
30
30
|
## Usage
|
|
31
31
|
|
|
@@ -35,15 +35,21 @@ semtag [options]
|
|
|
35
35
|
|
|
36
36
|
### Options
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
|
|
46
|
-
-
|
|
38
|
+
<!-- OPTIONS:START -->
|
|
39
|
+
```
|
|
40
|
+
-h, --help show this help message and exit
|
|
41
|
+
-v, --verbose Verbosity (-v for INFO, -vv for DEBUG)
|
|
42
|
+
-b, --by BY Increment by a specific number
|
|
43
|
+
-p, --patch Increment patch version (x.x.PATCH)
|
|
44
|
+
-m, --minor Increment minor version (x.MINOR.0)
|
|
45
|
+
-M, --major Increment major version (MAJOR.0.0)
|
|
46
|
+
-l, --label LABEL Add label to the version (e.g., -l rc1 creates 1.0.0-rc1)
|
|
47
|
+
-a, --msg MSG Annotated tags message
|
|
48
|
+
-u, --push Push the new tag to remote repository
|
|
49
|
+
-U, --pushall Push all local tags to remote repository
|
|
50
|
+
-n, --no-fetch Do not fetch tags from remote before operation
|
|
51
|
+
```
|
|
52
|
+
<!-- OPTIONS:END -->
|
|
47
53
|
|
|
48
54
|
### Examples
|
|
49
55
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
SemanticVersion.py,sha256=twzdlvhigapvxv5b4dDNYUKtq4FGnga6MYeo5bnVfoA,2783
|
|
2
|
+
semtag.py,sha256=qz3ogaJetkEQy9eMMLIzH6g_VTGaj7n0yscZFVS6kxs,5716
|
|
3
|
+
semtag-0.2.1.dist-info/licenses/LICENSE,sha256=Btzdu2kIoMbdSp6OyCLupB1aRgpTCJ_szMimgEnpkkE,1056
|
|
4
|
+
semtag-0.2.1.dist-info/METADATA,sha256=EbYajEPDeA0WdQidSkGdVpVUnAC0Ipt218H05dfqzeE,2762
|
|
5
|
+
semtag-0.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
6
|
+
semtag-0.2.1.dist-info/entry_points.txt,sha256=vojSwqU_Ojr1MuLJE4gzbN4KDK-MObwL8VSNvpsaTGA,39
|
|
7
|
+
semtag-0.2.1.dist-info/top_level.txt,sha256=AfmWqKvB5cvvtynjVHYSYv0Qctx4XLUdhnChNRLiz1E,23
|
|
8
|
+
semtag-0.2.1.dist-info/RECORD,,
|
semtag.py
CHANGED
|
@@ -14,19 +14,12 @@ logger = logging.getLogger(__name__)
|
|
|
14
14
|
|
|
15
15
|
def main():
|
|
16
16
|
""" Main function """
|
|
17
|
-
|
|
18
|
-
###
|
|
19
|
-
########################
|
|
17
|
+
|
|
18
|
+
### Arguments
|
|
20
19
|
parser = argparse.ArgumentParser(
|
|
21
20
|
description='SemTag - Manage semantic version tags in git repositories',
|
|
22
21
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
23
|
-
epilog=""
|
|
24
|
-
Examples:
|
|
25
|
-
%(prog)s -m # Increment minor version (1.0.0 -> 1.1.0)
|
|
26
|
-
%(prog)s -M # Increment major version (1.0.0 -> 2.0.0)
|
|
27
|
-
%(prog)s -p -b 5 # Increment patch version by 5 (1.0.0 -> 1.0.5)
|
|
28
|
-
%(prog)s -p -l rc1 # Increment patch and add label (1.0.0 -> 1.0.1-rc1)
|
|
29
|
-
"""
|
|
22
|
+
epilog="\n"
|
|
30
23
|
)
|
|
31
24
|
parser.add_argument('-v', '--verbose', action='count', default=0, help='Verbosity (-v for INFO, -vv for DEBUG)')
|
|
32
25
|
# parser.add_argument('-f', '--force', action='store_true', default=False, help='Force the operation even if not on main/master branch')
|
|
@@ -38,11 +31,13 @@ Examples:
|
|
|
38
31
|
version_group.add_argument('-M', '--major', action='store_true', help='Increment major version (MAJOR.0.0)')
|
|
39
32
|
|
|
40
33
|
parser.add_argument('-l', '--label', type=str, default=None, help='Add label to the version (e.g., -l rc1 creates 1.0.0-rc1)')
|
|
34
|
+
parser.add_argument('-a', '--msg', type=str, help='Annotated tags message', default=None)
|
|
41
35
|
parser.add_argument('-u', '--push', action='store_true', help='Push the new tag to remote repository', default=False)
|
|
36
|
+
parser.add_argument('-U', '--pushall', action='store_true', help='Push all local tags to remote repository', default=False)
|
|
42
37
|
parser.add_argument('-n', '--no-fetch', action='store_true', help='Do not fetch tags from remote before operation', default=False)
|
|
43
38
|
args = parser.parse_args()
|
|
44
39
|
|
|
45
|
-
### Logging based on verbosity
|
|
40
|
+
### Logging based on verbosity
|
|
46
41
|
if args.verbose == 0:
|
|
47
42
|
log_level = logging.WARNING
|
|
48
43
|
elif args.verbose == 1:
|
|
@@ -54,14 +49,12 @@ Examples:
|
|
|
54
49
|
level=log_level,
|
|
55
50
|
format='%(message)s' # Keep it simple (no timestamps, severity etc.)
|
|
56
51
|
)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
### Main Logic ###
|
|
60
|
-
##################
|
|
52
|
+
|
|
53
|
+
### Main Logic
|
|
61
54
|
logger.debug(f"Arguments: {args}")
|
|
62
55
|
pwd = Path('.').resolve()
|
|
63
56
|
|
|
64
|
-
### Check if this is a git workspace
|
|
57
|
+
### Check if this is a git workspace
|
|
65
58
|
try:
|
|
66
59
|
repo = git.Repo(pwd, search_parent_directories=True)
|
|
67
60
|
logger.debug(f"Found git repository at {repo.working_dir}")
|
|
@@ -73,7 +66,7 @@ Examples:
|
|
|
73
66
|
exit(99)
|
|
74
67
|
|
|
75
68
|
reponame = Path(repo.working_dir).name
|
|
76
|
-
logger.
|
|
69
|
+
logger.info(f"Repository name : {reponame}")
|
|
77
70
|
|
|
78
71
|
## Check if on main/master branch (warning only)
|
|
79
72
|
# try:
|
|
@@ -84,30 +77,31 @@ Examples:
|
|
|
84
77
|
# logger.warning("HEAD is detached, not on any branch")
|
|
85
78
|
# exit(2)
|
|
86
79
|
|
|
87
|
-
|
|
88
|
-
# Fetch tags from remote to avoid duplicates
|
|
80
|
+
### Fetch tags from remote to avoid duplicates
|
|
89
81
|
if not args.no_fetch:
|
|
90
82
|
try:
|
|
91
83
|
logger.debug("Fetching tags from remote...")
|
|
92
84
|
repo.remotes.origin.fetch(tags=True)
|
|
93
|
-
logger.
|
|
85
|
+
logger.info("Tags fetched successfully")
|
|
94
86
|
except Exception as e:
|
|
95
87
|
logger.warning(f"Error fetching tags: {e}")
|
|
96
|
-
|
|
88
|
+
|
|
89
|
+
### Sort and filter semantic tags
|
|
90
|
+
logger.debug(f"All tags in repository: {repo.tags}")
|
|
97
91
|
tags = semsort([tag.name for tag in repo.tags])
|
|
92
|
+
logger.debug(f"Sorted semantic tags: {tags}")
|
|
98
93
|
|
|
94
|
+
### No tags case
|
|
99
95
|
if tags:
|
|
100
96
|
latest_tag = tags[0]
|
|
101
|
-
logger.
|
|
97
|
+
logger.info(f"Latest semantic version tag: {latest_tag}")
|
|
102
98
|
else:
|
|
103
|
-
# No tags found, start with 0.0.0
|
|
104
|
-
logger.debug("No semantic version tags found. Starting with 0.0.0")
|
|
105
99
|
latest_tag = '0.0.0'
|
|
100
|
+
logger.info("No semantic version tags found. Starting with 0.0.0")
|
|
106
101
|
|
|
107
|
-
# Initialize obj
|
|
108
102
|
current_version = SemanticVersion(latest_tag)
|
|
109
103
|
|
|
110
|
-
### Increment version
|
|
104
|
+
### Increment version
|
|
111
105
|
if args.major:
|
|
112
106
|
logger.debug("Incrementing major version")
|
|
113
107
|
current_version.inc_major(by=args.by)
|
|
@@ -118,24 +112,32 @@ Examples:
|
|
|
118
112
|
logger.debug("Incrementing patch version")
|
|
119
113
|
current_version.inc_patch(by=args.by)
|
|
120
114
|
|
|
121
|
-
### Label
|
|
115
|
+
### Label
|
|
122
116
|
if args.label:
|
|
123
117
|
logger.debug(f"Adding label: {args.label}")
|
|
124
118
|
current_version.add_label(args.label)
|
|
125
119
|
|
|
126
120
|
new_tag = str(current_version)
|
|
127
|
-
logger.
|
|
121
|
+
logger.debug(f"Generated new tag: {new_tag}")
|
|
128
122
|
|
|
129
|
-
### Create
|
|
123
|
+
### Create tag
|
|
130
124
|
try:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
125
|
+
if args.msg:
|
|
126
|
+
logger.debug(f"Creating annotated tag '{new_tag}' with message: {args.msg}")
|
|
127
|
+
repo.create_tag(new_tag, message=args.msg)
|
|
128
|
+
else:
|
|
129
|
+
logger.debug(f"Creating lightweight tag '{new_tag}'")
|
|
130
|
+
repo.create_tag(new_tag)
|
|
131
|
+
|
|
134
132
|
logger.info(f"Successfully created tag: {new_tag}")
|
|
135
133
|
|
|
136
|
-
|
|
137
|
-
if args.
|
|
138
|
-
logger.
|
|
134
|
+
### Push
|
|
135
|
+
if args.pushall:
|
|
136
|
+
logger.debug("Pushing all local tags to remote...")
|
|
137
|
+
repo.remote('origin').push(tags=True)
|
|
138
|
+
logger.info("Successfully pushed all tags to remote")
|
|
139
|
+
elif args.push:
|
|
140
|
+
logger.debug(f"Pushing tag '{new_tag}' to remote...")
|
|
139
141
|
repo.remote('origin').push(new_tag) # It only pushes the new tag not all from local repo
|
|
140
142
|
logger.info(f"Successfully pushed new tag: {new_tag}")
|
|
141
143
|
else:
|
|
@@ -145,7 +147,7 @@ Examples:
|
|
|
145
147
|
except Exception as e:
|
|
146
148
|
logger.error(f"Error: {e}")
|
|
147
149
|
|
|
148
|
-
|
|
150
|
+
### Print the new tag to stout as confirmation if not verbose
|
|
149
151
|
if args.verbose == 0:
|
|
150
152
|
GREEN = '\033[92m'
|
|
151
153
|
YELLOW = '\033[93m'
|
semtag-0.1.3.dist-info/RECORD
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
SemanticVersion.py,sha256=twzdlvhigapvxv5b4dDNYUKtq4FGnga6MYeo5bnVfoA,2783
|
|
2
|
-
semtag.py,sha256=9pr2pPB_WKUs1NBe5mKm2hDmFSwLJxY3xrCJvU3fDLA,5537
|
|
3
|
-
semtag-0.1.3.dist-info/licenses/LICENSE,sha256=Btzdu2kIoMbdSp6OyCLupB1aRgpTCJ_szMimgEnpkkE,1056
|
|
4
|
-
semtag-0.1.3.dist-info/METADATA,sha256=p8De-KzqAuxPoBnlqAfuW1dD4TkOmdl9pocPikm_VKc,2642
|
|
5
|
-
semtag-0.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
6
|
-
semtag-0.1.3.dist-info/entry_points.txt,sha256=vojSwqU_Ojr1MuLJE4gzbN4KDK-MObwL8VSNvpsaTGA,39
|
|
7
|
-
semtag-0.1.3.dist-info/top_level.txt,sha256=AfmWqKvB5cvvtynjVHYSYv0Qctx4XLUdhnChNRLiz1E,23
|
|
8
|
-
semtag-0.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|