gitnextver 1.0.0__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.
gitnextver/__init__.py ADDED
@@ -0,0 +1,12 @@
1
+ # this_file: src/gitnextver/__init__.py
2
+ """gitnextver - Automatically bump semantic version tags in Git repositories."""
3
+
4
+ try:
5
+ from gitnextver.__version__ import __version__
6
+ except ImportError:
7
+ from importlib.metadata import version, PackageNotFoundError
8
+
9
+ try:
10
+ __version__ = version("gitnextver")
11
+ except PackageNotFoundError:
12
+ __version__ = "0.0.0"
gitnextver/__main__.py ADDED
@@ -0,0 +1,7 @@
1
+ # this_file: src/gitnextver/__main__.py
2
+ """Entry point for `python -m gitnextver`."""
3
+
4
+ from gitnextver.cli import app
5
+
6
+ if __name__ == "__main__":
7
+ app()
@@ -0,0 +1,24 @@
1
+ # file generated by vcs-versioning
2
+ # don't change, don't track in version control
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "version",
9
+ "version_tuple",
10
+ "__commit_id__",
11
+ "commit_id",
12
+ ]
13
+
14
+ version: str
15
+ __version__: str
16
+ __version_tuple__: tuple[int | str, ...]
17
+ version_tuple: tuple[int | str, ...]
18
+ commit_id: str | None
19
+ __commit_id__: str | None
20
+
21
+ __version__ = version = '1.0.0'
22
+ __version_tuple__ = version_tuple = (1, 0, 0)
23
+
24
+ __commit_id__ = commit_id = None
gitnextver/cli.py ADDED
@@ -0,0 +1,448 @@
1
+ # this_file: src/gitnextver/cli.py
2
+
3
+ """
4
+ Git Next Version Tool - Automatically bump version tags and commit changes.
5
+
6
+ This tool:
7
+ 1. Checks if we're in a git repo
8
+ 2. Pulls from remote repo
9
+ 3. Handles conflicts gracefully
10
+ 4. Determines next version tag based on existing tags
11
+ 5. Commits all changes with version tag
12
+ 6. Creates and pushes the new tag
13
+ """
14
+
15
+ import re
16
+ import sys
17
+ from pathlib import Path
18
+ from typing import Optional
19
+
20
+ import fire # type: ignore
21
+ import git
22
+ from git.exc import GitCommandError, InvalidGitRepositoryError
23
+ from loguru import logger
24
+ from rich.console import Console
25
+ from rich.panel import Panel
26
+ from rich.text import Text
27
+
28
+ console = Console()
29
+
30
+ # Pre-compiled regex to match semantic version tags like v1.2.3
31
+ VERSION_PATTERN = re.compile(r"^v(\d+)\.(\d+)\.(\d+)$")
32
+
33
+ # Friendly default remote name
34
+ DEFAULT_REMOTE_NAME = "origin"
35
+
36
+
37
+ def setup_logging(verbose: bool = False) -> None:
38
+ """Setup logging configuration."""
39
+ logger.remove()
40
+ level = "DEBUG" if verbose else "INFO"
41
+ logger.add(
42
+ sys.stderr,
43
+ format=(
44
+ "<green>{time:YYYY-MM-DD HH:mm:ss}</green> | "
45
+ "<level>{level: <8}</level> | <level>{message}</level>"
46
+ ),
47
+ level=level,
48
+ )
49
+
50
+
51
+ def is_git_repo(path: Path) -> bool:
52
+ """Check if the given path is a git repository."""
53
+ try:
54
+ git.Repo(path)
55
+ return True
56
+ except InvalidGitRepositoryError:
57
+ return False
58
+
59
+
60
+ def get_last_version_tag(repo: git.Repo) -> Optional[str]:
61
+ """Get the last version tag in vA.B.C format."""
62
+ tags = repo.tags
63
+ version_tags = []
64
+
65
+ for tag in tags:
66
+ match = VERSION_PATTERN.match(tag.name)
67
+ if match:
68
+ major, minor, patch = map(int, match.groups())
69
+ version_tags.append((major, minor, patch, tag.name))
70
+
71
+ if not version_tags:
72
+ return None
73
+
74
+ # Pick the tag with the highest numerical value
75
+ latest = max(version_tags, key=lambda x: (x[0], x[1], x[2]))
76
+ return latest[3]
77
+
78
+
79
+ def calculate_next_version(last_tag: Optional[str]) -> str:
80
+ """Calculate the next version tag."""
81
+ if not last_tag:
82
+ return "v1.0.0"
83
+
84
+ match = VERSION_PATTERN.match(last_tag)
85
+
86
+ if not match:
87
+ return "v1.0.0"
88
+
89
+ major, minor, patch = map(int, match.groups())
90
+ return f"v{major}.{minor}.{patch + 1}"
91
+
92
+
93
+ def _select_remote(repo: git.Repo):
94
+ """Return a remote to interact with, or *None* if no remotes exist."""
95
+ remotes = {r.name: r for r in repo.remotes}
96
+ if DEFAULT_REMOTE_NAME in remotes:
97
+ return remotes[DEFAULT_REMOTE_NAME]
98
+ # Fallback to any remote if 'origin' is missing
99
+ return next(iter(remotes.values())) if remotes else None
100
+
101
+
102
+ def stash_uncommitted_changes(repo: git.Repo) -> bool:
103
+ """Stash any uncommitted (including untracked) changes before a pull.
104
+
105
+ Returns True if a stash was created, False otherwise.
106
+ """
107
+ if repo.is_dirty(untracked_files=True) or repo.untracked_files:
108
+ logger.info("Stashing uncommitted changes before pull …")
109
+ try:
110
+ # Include untracked files to ensure a clean working tree
111
+ repo.git.stash(
112
+ "push",
113
+ "--include-untracked",
114
+ "-m",
115
+ "gitnextver-auto-stash",
116
+ )
117
+ return True
118
+ except GitCommandError as e:
119
+ if "could not write index" in str(e):
120
+ # Try to fix index corruption
121
+ logger.warning("Git index appears corrupted, attempting to fix...")
122
+ try:
123
+ # Remove index lock if it exists
124
+ index_lock = Path(repo.git_dir) / "index.lock"
125
+ if index_lock.exists():
126
+ index_lock.unlink()
127
+ logger.info("Removed stale index.lock file")
128
+
129
+ # Reset the index
130
+ repo.git.reset("--mixed")
131
+ logger.info("Reset git index")
132
+
133
+ # Try stash again
134
+ repo.git.stash(
135
+ "push",
136
+ "--include-untracked",
137
+ "-m",
138
+ "gitnextver-auto-stash",
139
+ )
140
+ return True
141
+ except Exception as fix_error:
142
+ logger.error(f"Failed to fix git index: {fix_error}")
143
+ console.print(
144
+ Panel(
145
+ Text(
146
+ "Git index is corrupted. Try running:\n"
147
+ "rm -f .git/index.lock\n"
148
+ "git reset --mixed",
149
+ style="bold red",
150
+ ),
151
+ title="❌ Git Index Error",
152
+ border_style="red",
153
+ )
154
+ )
155
+ raise
156
+ else:
157
+ raise
158
+ return False
159
+
160
+
161
+ def apply_latest_stash(repo: git.Repo) -> bool:
162
+ """Apply (pop) the most recent stash if one exists.
163
+
164
+ Returns True when the stash is successfully applied (or none existed).
165
+ Returns False when applying the stash leads to merge conflicts or other
166
+ errors that require manual user intervention.
167
+ """
168
+ stash_list = repo.git.stash("list").strip()
169
+ if not stash_list:
170
+ # Nothing to apply
171
+ return True
172
+
173
+ try:
174
+ logger.info("Re-applying stashed changes …")
175
+ repo.git.stash("pop")
176
+ logger.info("Successfully re-applied stashed changes")
177
+ return True
178
+ except GitCommandError as exc:
179
+ message = str(exc)
180
+ if "CONFLICT" in message.upper():
181
+ logger.error("Applying stash resulted in conflicts")
182
+ console.print(
183
+ Panel(
184
+ Text(
185
+ "Applying stashed changes resulted in "
186
+ "merge conflicts!\n\n"
187
+ "Please resolve conflicts manually and run the "
188
+ "command again.",
189
+ style="bold red",
190
+ ),
191
+ title="❌ Merge Conflict",
192
+ border_style="red",
193
+ )
194
+ )
195
+ return False
196
+
197
+ logger.error(f"Failed to apply stash: {exc}")
198
+ console.print(
199
+ Panel(
200
+ Text(f"Failed to apply stash: {exc}", style="bold red"),
201
+ title="❌ Stash Error",
202
+ border_style="red",
203
+ )
204
+ )
205
+ return False
206
+
207
+
208
+ def pull_with_conflict_check(repo: git.Repo) -> bool:
209
+ """Pull from the selected remote and check for merge conflicts.
210
+
211
+ Returns True on success, False if a conflict or pull failure occurred.
212
+ If no remote is configured, the function logs a warning and returns
213
+ True (nothing to pull).
214
+ """
215
+ remote = _select_remote(repo)
216
+
217
+ if remote is None:
218
+ logger.warning("No git remotes configured – skipping pull step.")
219
+ return True
220
+
221
+ try:
222
+ logger.info(f"Pulling from remote '{remote.name}' …")
223
+ remote.pull()
224
+ logger.info("Successfully pulled from remote")
225
+ return True
226
+ except GitCommandError as exc:
227
+ if "CONFLICT" in str(exc).upper():
228
+ logger.error("Git pull resulted in conflicts")
229
+ console.print(
230
+ Panel(
231
+ Text(
232
+ "Git pull resulted in merge conflicts!\n\n"
233
+ "Please resolve conflicts manually and run the "
234
+ "command again.",
235
+ style="bold red",
236
+ ),
237
+ title="❌ Merge Conflict",
238
+ border_style="red",
239
+ )
240
+ )
241
+ return False
242
+
243
+ logger.error(f"Git pull failed: {exc}")
244
+ console.print(
245
+ Panel(
246
+ Text(f"Git pull failed: {exc}", style="bold red"),
247
+ title="❌ Pull Error",
248
+ border_style="red",
249
+ )
250
+ )
251
+ return False
252
+
253
+
254
+ def ensure_gitpython_compatibility(repo: git.Repo) -> None:
255
+ """Ensure git index is compatible with GitPython by downgrading if needed."""
256
+ try:
257
+ # Test if GitPython can read the index
258
+ _ = repo.index.entries
259
+ except AssertionError as e:
260
+ # The AssertionError from GitPython index version incompatibility
261
+ logger.warning(f"Git index version incompatible with GitPython: {e}")
262
+ logger.warning("Attempting to downgrade git index to version 2...")
263
+ try:
264
+ # Downgrade index to version 2 (compatible with GitPython)
265
+ repo.git.update_index("--index-version", "2")
266
+ logger.info("Successfully downgraded git index to version 2")
267
+
268
+ # Verify the fix worked by testing index access again
269
+ _ = repo.index.entries
270
+ logger.info("GitPython can now access the git index")
271
+ except GitCommandError as downgrade_error:
272
+ logger.error(f"Failed to downgrade git index: {downgrade_error}")
273
+ raise
274
+ except Exception as verify_error:
275
+ logger.error(f"Git index still incompatible after downgrade: {verify_error}")
276
+ raise
277
+
278
+
279
+ def commit_and_tag(
280
+ repo: git.Repo,
281
+ version: str,
282
+ verbose: bool = False,
283
+ ) -> None:
284
+ """Add all files, commit, create tag, and push."""
285
+ try:
286
+ # Add all untracked and modified files
287
+ logger.info("Adding all untracked and modified files...")
288
+ repo.git.add(A=True)
289
+
290
+ # Check if there are any changes to commit
291
+ if not repo.is_dirty() and not repo.untracked_files:
292
+ logger.warning("No changes to commit")
293
+ console.print(
294
+ Panel(
295
+ Text("No changes found to commit", style="yellow"),
296
+ title="⚠️ Warning",
297
+ border_style="yellow",
298
+ )
299
+ )
300
+ return
301
+
302
+ # Ensure GitPython compatibility before committing
303
+ ensure_gitpython_compatibility(repo)
304
+
305
+ # Commit with version as message
306
+ logger.info(f"Committing changes with message: {version}")
307
+ repo.index.commit(version)
308
+
309
+ # Create tag
310
+ logger.info(f"Creating tag: {version}")
311
+ repo.create_tag(version)
312
+
313
+ # Push commits and tags
314
+ logger.info("Pushing commits and tags to remote...")
315
+ remote = _select_remote(repo)
316
+ if remote is None:
317
+ logger.warning("No remotes configured – skipping push step.")
318
+ else:
319
+ remote.push()
320
+ remote.push(tags=True)
321
+
322
+ console.print(
323
+ Panel(
324
+ Text(
325
+ f"✅ Successfully created and pushed version {version}",
326
+ style="bold green",
327
+ ),
328
+ title="🎉 Success",
329
+ border_style="green",
330
+ )
331
+ )
332
+
333
+ except GitCommandError as e:
334
+ logger.error(f"Git operation failed: {e}")
335
+ console.print(
336
+ Panel(
337
+ Text(f"Git operation failed: {str(e)}", style="bold red"),
338
+ title="❌ Git Error",
339
+ border_style="red",
340
+ )
341
+ )
342
+ sys.exit(1)
343
+
344
+
345
+ def main(directory: Optional[str] = None, verbose: bool = False) -> None:
346
+ """
347
+ Main function to handle git version tagging.
348
+
349
+ Args:
350
+ directory: Directory to work in (defaults to current directory)
351
+ verbose: Enable verbose logging
352
+ """
353
+ setup_logging(verbose)
354
+
355
+ # Determine working directory
356
+ work_dir = Path(directory) if directory else Path.cwd()
357
+ work_dir = work_dir.resolve()
358
+
359
+ logger.info(f"Working in directory: {work_dir}")
360
+
361
+ # Check if it's a git repository
362
+ if not is_git_repo(work_dir):
363
+ console.print(
364
+ Panel(
365
+ Text(
366
+ f"Directory {work_dir} is not a git repository!",
367
+ style="bold red",
368
+ ),
369
+ title="❌ Not a Git Repository",
370
+ border_style="red",
371
+ )
372
+ )
373
+ sys.exit(1)
374
+
375
+ # Initialize git repo object
376
+ repo = git.Repo(work_dir)
377
+
378
+ # Ensure git index is compatible with GitPython early on
379
+ try:
380
+ ensure_gitpython_compatibility(repo)
381
+ except Exception as e:
382
+ logger.error(f"Failed to ensure GitPython compatibility: {e}")
383
+ console.print(
384
+ Panel(
385
+ Text(
386
+ f"Git index compatibility issue: {e}\n\n"
387
+ "This may be due to a newer git index version. "
388
+ "Try running: git update-index --index-version=2",
389
+ style="bold red",
390
+ ),
391
+ title="❌ Git Index Error",
392
+ border_style="red",
393
+ )
394
+ )
395
+ sys.exit(1)
396
+
397
+ # If there are local changes, stash them so that pull can proceed safely
398
+ had_stash = stash_uncommitted_changes(repo)
399
+
400
+ # Pull from remote
401
+ if not pull_with_conflict_check(repo):
402
+ # If pull failed and we created a stash, attempt to restore it so the
403
+ # user does not lose their work (even though they may need to resolve
404
+ # issues manually afterwards).
405
+ if had_stash:
406
+ try:
407
+ repo.git.stash("pop")
408
+ except GitCommandError:
409
+ # If even restoring fails we still proceed to exit – the user
410
+ # has to handle the situation manually.
411
+ pass
412
+ sys.exit(1)
413
+
414
+ # Re-apply stashed changes (if any)
415
+ if had_stash and not apply_latest_stash(repo):
416
+ sys.exit(1)
417
+
418
+ # Get last version tag
419
+ last_tag = get_last_version_tag(repo)
420
+ logger.info(f"Last version tag: {last_tag if last_tag else 'None found'}")
421
+
422
+ # Calculate next version
423
+ next_version = calculate_next_version(last_tag)
424
+ logger.info(f"Next version will be: {next_version}")
425
+
426
+ console.print(
427
+ Panel(
428
+ Text(
429
+ f"Current version: {last_tag if last_tag else 'None'}\n"
430
+ f"Next version: {next_version}",
431
+ style="bold blue",
432
+ ),
433
+ title="📋 Version Info",
434
+ border_style="blue",
435
+ )
436
+ )
437
+
438
+ # Commit and tag
439
+ commit_and_tag(repo, next_version, verbose)
440
+
441
+
442
+ def app() -> None:
443
+ """CLI entry point for gitnextver."""
444
+ fire.Fire(main)
445
+
446
+
447
+ if __name__ == "__main__":
448
+ app()
@@ -0,0 +1,72 @@
1
+ Metadata-Version: 2.4
2
+ Name: gitnextver
3
+ Version: 1.0.0
4
+ Summary: Automatically bump semantic version tags in Git repositories
5
+ Project-URL: Homepage, https://github.com/twardoch/gitnextver
6
+ Project-URL: Repository, https://github.com/twardoch/gitnextver
7
+ Project-URL: Issues, https://github.com/twardoch/gitnextver/issues
8
+ Author-email: Adam Twardoch <adam+github@twardoch.com>
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: bump,git,semver,tag,version
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Version Control :: Git
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: fire
25
+ Requires-Dist: gitpython
26
+ Requires-Dist: loguru
27
+ Requires-Dist: rich
28
+ Description-Content-Type: text/markdown
29
+
30
+ # gitnextver
31
+
32
+ Automatically bump semantic version tags in Git repositories.
33
+
34
+ ## Installation
35
+
36
+ ```
37
+ pip install gitnextver
38
+ ```
39
+
40
+ Or run directly:
41
+
42
+ ```
43
+ uvx gitnextver
44
+ ```
45
+
46
+ ## Usage
47
+
48
+ ```bash
49
+ # Bump patch version in current directory
50
+ gitnextver
51
+
52
+ # Specify directory
53
+ gitnextver --directory /path/to/repo
54
+
55
+ # Verbose output
56
+ gitnextver --verbose
57
+ ```
58
+
59
+ ## What it does
60
+
61
+ 1. Validates you're in a git repository
62
+ 2. Stashes uncommitted changes
63
+ 3. Pulls from remote with conflict detection
64
+ 4. Re-applies stashed changes
65
+ 5. Finds the latest `vX.Y.Z` tag and increments the patch version
66
+ 6. Commits all changes, creates the tag, and pushes
67
+
68
+ Defaults to `v1.0.0` if no version tags exist.
69
+
70
+ ## License
71
+
72
+ Apache-2.0
@@ -0,0 +1,9 @@
1
+ gitnextver/__init__.py,sha256=WEYBZj7usBug2FrWZ_7asVmPhk7w5jT8gR_H7Ummba0,380
2
+ gitnextver/__main__.py,sha256=AA_oAJzo-8CCKDgXY5ii9kLFknehZ937oMjb1_DA268,156
3
+ gitnextver/__version__.py,sha256=JAAyU3al4wmBf3BF-Umm1J_GrCIT-yS_yWEGHqKRVHc,520
4
+ gitnextver/cli.py,sha256=fj7FE474c0WmNcEPdl3s4Ke2CnG3OmixQeDKXgb-5yU,14402
5
+ gitnextver-1.0.0.dist-info/METADATA,sha256=SH08XqjLxuSJDGjJC0EB4YmpAkPRn7PuzqfkMwvgUYk,1861
6
+ gitnextver-1.0.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
7
+ gitnextver-1.0.0.dist-info/entry_points.txt,sha256=zZzHMre1PdHinCbzus3i6ZhHpLrh6IISDFL7DQLsVbk,50
8
+ gitnextver-1.0.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
9
+ gitnextver-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ gitnextver = gitnextver.cli:app
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.