lastversion 3.6.2__tar.gz → 3.6.4__tar.gz

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.
Files changed (57) hide show
  1. {lastversion-3.6.2/src/lastversion.egg-info → lastversion-3.6.4}/PKG-INFO +1 -1
  2. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/__about__.py +1 -1
  3. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/cli.py +3 -1
  4. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/lastversion.py +6 -3
  5. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/repo_holders/github.py +57 -3
  6. {lastversion-3.6.2 → lastversion-3.6.4/src/lastversion.egg-info}/PKG-INFO +1 -1
  7. {lastversion-3.6.2 → lastversion-3.6.4}/tests/test_github.py +35 -0
  8. {lastversion-3.6.2 → lastversion-3.6.4}/LICENSE +0 -0
  9. {lastversion-3.6.2 → lastversion-3.6.4}/MANIFEST.in +0 -0
  10. {lastversion-3.6.2 → lastversion-3.6.4}/README-ZH-CN.md +0 -0
  11. {lastversion-3.6.2 → lastversion-3.6.4}/README.md +0 -0
  12. {lastversion-3.6.2 → lastversion-3.6.4}/pyproject.toml +0 -0
  13. {lastversion-3.6.2 → lastversion-3.6.4}/setup.cfg +0 -0
  14. {lastversion-3.6.2 → lastversion-3.6.4}/setup.py +0 -0
  15. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/__init__.py +0 -0
  16. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/__main__.py +0 -0
  17. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/ai.py +0 -0
  18. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/argparse_version.py +0 -0
  19. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/cache.py +0 -0
  20. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/config.py +0 -0
  21. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/exceptions.py +0 -0
  22. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/holder_factory.py +0 -0
  23. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/repo_holders/__init__.py +0 -0
  24. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/repo_holders/alpine.py +0 -0
  25. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/repo_holders/base.py +0 -0
  26. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/repo_holders/bibucket.py +0 -0
  27. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/repo_holders/feed.py +0 -0
  28. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/repo_holders/gitea.py +0 -0
  29. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/repo_holders/gitlab.py +0 -0
  30. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/repo_holders/helmchat.py +0 -0
  31. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/repo_holders/local.py +0 -0
  32. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/repo_holders/mercurial.py +0 -0
  33. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/repo_holders/pypi.py +0 -0
  34. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/repo_holders/sourceforge.py +0 -0
  35. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/repo_holders/system.py +0 -0
  36. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/repo_holders/test.py +0 -0
  37. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/repo_holders/wikipedia.py +0 -0
  38. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/repo_holders/wordpress.py +0 -0
  39. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/spdx_id_to_rpmspec.py +0 -0
  40. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/utils.py +0 -0
  41. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion/version.py +0 -0
  42. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion.egg-info/SOURCES.txt +0 -0
  43. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion.egg-info/dependency_links.txt +0 -0
  44. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion.egg-info/entry_points.txt +0 -0
  45. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion.egg-info/not-zip-safe +0 -0
  46. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion.egg-info/requires.txt +0 -0
  47. {lastversion-3.6.2 → lastversion-3.6.4}/src/lastversion.egg-info/top_level.txt +0 -0
  48. {lastversion-3.6.2 → lastversion-3.6.4}/tests/test_alpine.py +0 -0
  49. {lastversion-3.6.2 → lastversion-3.6.4}/tests/test_cache.py +0 -0
  50. {lastversion-3.6.2 → lastversion-3.6.4}/tests/test_cli.py +0 -0
  51. {lastversion-3.6.2 → lastversion-3.6.4}/tests/test_gitea.py +0 -0
  52. {lastversion-3.6.2 → lastversion-3.6.4}/tests/test_gitlab.py +0 -0
  53. {lastversion-3.6.2 → lastversion-3.6.4}/tests/test_hg.py +0 -0
  54. {lastversion-3.6.2 → lastversion-3.6.4}/tests/test_lastversion.py +0 -0
  55. {lastversion-3.6.2 → lastversion-3.6.4}/tests/test_pypi.py +0 -0
  56. {lastversion-3.6.2 → lastversion-3.6.4}/tests/test_sf.py +0 -0
  57. {lastversion-3.6.2 → lastversion-3.6.4}/tests/test_wiki.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lastversion
3
- Version: 3.6.2
3
+ Version: 3.6.4
4
4
  Summary: A CLI tool to find the latest stable version of an arbitrary project
5
5
  Home-page: https://github.com/dvershinin/lastversion
6
6
  Author: Danila Vershinin
@@ -1,4 +1,4 @@
1
1
  """Package metadata"""
2
2
 
3
- __version__ = "3.6.2"
3
+ __version__ = "3.6.4"
4
4
  __self__ = "dvershinin/lastversion"
@@ -230,6 +230,7 @@ def process_bulk_input(args):
230
230
  only=args.only,
231
231
  even=args.even,
232
232
  cache_ttl=args.cache_ttl,
233
+ skip_release_cache=args.no_cache,
233
234
  )
234
235
  if result:
235
236
  if args.format == "json":
@@ -444,7 +445,7 @@ def main(argv=None):
444
445
  "--no-cache",
445
446
  dest="no_cache",
446
447
  action="store_true",
447
- help="Do not use cache for HTTP requests",
448
+ help="Do not use cache (both HTTP requests and release data cache)",
448
449
  )
449
450
  parser.add_argument(
450
451
  "--cache-ttl",
@@ -620,6 +621,7 @@ def main(argv=None):
620
621
  formal=args.formal,
621
622
  changelog=args.changelog,
622
623
  cache_ttl=args.cache_ttl,
624
+ skip_release_cache=args.no_cache,
623
625
  )
624
626
  except (ApiCredentialsError, BadProjectError) as error:
625
627
  log.critical(str(error))
@@ -203,6 +203,7 @@ def latest(
203
203
  formal=False,
204
204
  changelog=False,
205
205
  cache_ttl=None,
206
+ skip_release_cache=False,
206
207
  ):
207
208
  r"""Find the latest release version for a project.
208
209
 
@@ -231,6 +232,8 @@ def latest(
231
232
  changelog (bool): Populate release["changelog"] using upstream notes (if True)
232
233
  cache_ttl (int): Optional TTL override for release data cache (seconds).
233
234
  Only used when release cache is enabled in config.
235
+ skip_release_cache (bool): Skip the release data cache entirely (both read and write).
236
+ Useful when you need fresh data from the source.
234
237
 
235
238
  Examples:
236
239
  Find the latest version of Mautic, it is OK to consider betas.
@@ -290,7 +293,7 @@ def latest(
290
293
  return cached_data
291
294
 
292
295
  # Try to get from cache for formats that can use cached data
293
- if release_cache.enabled and output_format in ["json", "dict", "version", "tag"]:
296
+ if release_cache.enabled and not skip_release_cache and output_format in ["json", "dict", "version", "tag"]:
294
297
  cached_release = release_cache.get(repo, **cache_key_params)
295
298
  if cached_release:
296
299
  result = _return_from_cache(cached_release, output_format, is_stale=False)
@@ -401,8 +404,8 @@ def latest(
401
404
 
402
405
  release["source_url"] = project.release_download_url(release, short_urls)
403
406
 
404
- # Store in release cache if enabled
405
- if release_cache.enabled:
407
+ # Store in release cache if enabled (skip if explicitly bypassing cache)
408
+ if release_cache.enabled and not skip_release_cache:
406
409
  release_cache.set(repo, release, ttl=cache_ttl, **cache_key_params)
407
410
 
408
411
  return release
@@ -603,6 +603,27 @@ class GitHubRepoSession(BaseProjectHolder):
603
603
  release["install_name"] = self.name
604
604
  return release or None
605
605
 
606
+ @staticmethod
607
+ def is_version_more_specific(version_a, version_b):
608
+ """Check if version_a is more specific than version_b.
609
+
610
+ A version is more specific if it has more release components and
611
+ starts with all the components of the less specific version.
612
+ E.g., 3.5.4 is more specific than 3.5.
613
+
614
+ Args:
615
+ version_a: The potentially more specific version.
616
+ version_b: The potentially less specific version.
617
+
618
+ Returns:
619
+ bool: True if version_a is more specific than version_b.
620
+ """
621
+ release_a = version_a.release
622
+ release_b = version_b.release
623
+ if len(release_a) > len(release_b):
624
+ return release_a[: len(release_b)] == release_b
625
+ return False
626
+
606
627
  def semver_check_skip(self, version, selected_release):
607
628
  """Should we skip this version from being selected based on semver."""
608
629
  if version.is_semver():
@@ -625,6 +646,15 @@ class GitHubRepoSession(BaseProjectHolder):
625
646
  if self.seen_semver and not version.is_semver():
626
647
  log.info("Version %s is not a semver and we already found a semver", version)
627
648
  return True
649
+ # Skip if the new version is less specific than the selected one
650
+ # e.g., skip 3.5 if we already have 3.5.4 (both under the 3.5 branch)
651
+ if comparable and self.is_version_more_specific(selected_release["version"], version):
652
+ log.info(
653
+ "Version %s is less specific than already selected %s",
654
+ version,
655
+ selected_release["version"],
656
+ )
657
+ return True
628
658
  return False
629
659
 
630
660
  def get_release_from_feed(self, pre_ok, major):
@@ -662,8 +692,17 @@ class GitHubRepoSession(BaseProjectHolder):
662
692
  )
663
693
  continue
664
694
  if ret and tag_date + timedelta(days=30) < ret["tag_date"]:
665
- log.info("The version %s is newer, but is too old!", version)
666
- break
695
+ # Don't break if the new version is more specific than the selected one
696
+ # e.g., continue processing 3.5.4 even if we selected 3.5 from a recent tag
697
+ if self.is_version_more_specific(version, ret["version"]):
698
+ log.info(
699
+ "Version %s is more specific than selected %s, continuing despite date",
700
+ version,
701
+ ret["version"],
702
+ )
703
+ else:
704
+ log.info("The version %s is newer, but is too old!", version)
705
+ break
667
706
  # we always want to return formal release if it exists, because it has useful data
668
707
  # grab formal release via APi to check for pre-release mark
669
708
  formal_release = self.get_formal_release_for_tag(tag_name)
@@ -709,7 +748,22 @@ class GitHubRepoSession(BaseProjectHolder):
709
748
  # simply because feeds list stuff in order of recency,
710
749
  # however, still use /tags unless releases.atom has data within a year
711
750
  if ret and ret["tag_date"].replace(tzinfo=None) > (datetime.utcnow() - timedelta(days=365)):
712
- return self.enrich_release_info(ret)
751
+ # Don't return early if the result is NOT a formal release and has a
752
+ # less-specific version (e.g., 3.5 instead of 3.5.x). In such cases,
753
+ # we should check the API for more specific formal releases.
754
+ # This handles cases where non-release tags like "3.5-POST-CLANG-FORMAT"
755
+ # are picked up from the feed but proper releases like "openssl-3.5.4"
756
+ # exist as formal releases. See issue #218.
757
+ is_non_formal = ret.get("type") == "feed"
758
+ version_components = len(ret["version"].release)
759
+ if is_non_formal and version_components < 3:
760
+ log.info(
761
+ "Feed result %s is non-formal with %d version components, checking API",
762
+ ret["version"],
763
+ version_components,
764
+ )
765
+ else:
766
+ return self.enrich_release_info(ret)
713
767
 
714
768
  log.info("Feed contained none or only tags older than 1 year. Switching to API")
715
769
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lastversion
3
- Version: 3.6.2
3
+ Version: 3.6.4
4
4
  Summary: A CLI tool to find the latest stable version of an arbitrary project
5
5
  Home-page: https://github.com/dvershinin/lastversion
6
6
  Author: Danila Vershinin
@@ -8,6 +8,8 @@ from packaging import version
8
8
 
9
9
  from lastversion.cli import main
10
10
  from lastversion.lastversion import latest
11
+ from lastversion.repo_holders.github import GitHubRepoSession
12
+ from lastversion.version import Version
11
13
  from tests.helpers import captured_exit_code
12
14
 
13
15
 
@@ -134,3 +136,36 @@ def test_github_temurin8_latest_tag():
134
136
  assert m is not None
135
137
  update_num = int(m.group(1))
136
138
  assert update_num >= 462
139
+
140
+
141
+ def test_is_version_more_specific():
142
+ """Test the is_version_more_specific helper method."""
143
+ # 3.5.4 is more specific than 3.5
144
+ assert GitHubRepoSession.is_version_more_specific(Version("3.5.4"), Version("3.5"))
145
+ # 3.5.4.1 is more specific than 3.5.4
146
+ assert GitHubRepoSession.is_version_more_specific(Version("3.5.4.1"), Version("3.5.4"))
147
+ # 3.5.4 is more specific than 3
148
+ assert GitHubRepoSession.is_version_more_specific(Version("3.5.4"), Version("3"))
149
+ # 3.5 is NOT more specific than 3.5.4
150
+ assert not GitHubRepoSession.is_version_more_specific(Version("3.5"), Version("3.5.4"))
151
+ # 3.5.4 is NOT more specific than 3.5.4 (same)
152
+ assert not GitHubRepoSession.is_version_more_specific(Version("3.5.4"), Version("3.5.4"))
153
+ # 3.6.0 is NOT more specific than 3.5 (different version line)
154
+ assert not GitHubRepoSession.is_version_more_specific(Version("3.6.0"), Version("3.5"))
155
+ # 2.5.4 is NOT more specific than 3.5 (different major)
156
+ assert not GitHubRepoSession.is_version_more_specific(Version("2.5.4"), Version("3.5"))
157
+
158
+
159
+ def test_github_openssl_branch_prefers_specific_version():
160
+ """
161
+ Test that when filtering by branch, a more specific version like 3.5.4 is
162
+ preferred over a less specific version like 3.5 (from a non-release tag).
163
+ This is a regression test for GitHub issue #218.
164
+ """
165
+ repo = "https://github.com/openssl/openssl"
166
+ output = latest(repo, major="3.5")
167
+ # Should return a version like 3.5.4, not just 3.5
168
+ assert output is not None
169
+ assert output > version.parse("3.5.0"), f"Expected version > 3.5.0, got {output}"
170
+ # Verify it starts with 3.5
171
+ assert str(output).startswith("3.5."), f"Expected version starting with 3.5., got {output}"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes