lastversion 3.5.3__tar.gz → 3.5.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.
- {lastversion-3.5.3/src/lastversion.egg-info → lastversion-3.5.4}/PKG-INFO +1 -1
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/__about__.py +2 -1
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/repo_holders/base.py +9 -3
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/repo_holders/github.py +86 -43
- {lastversion-3.5.3 → lastversion-3.5.4/src/lastversion.egg-info}/PKG-INFO +1 -1
- {lastversion-3.5.3 → lastversion-3.5.4}/tests/test_gitlab.py +2 -1
- {lastversion-3.5.3 → lastversion-3.5.4}/LICENSE +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/MANIFEST.in +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/README-ZH-CN.md +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/README.md +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/setup.cfg +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/setup.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/__init__.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/__main__.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/argparse_version.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/exceptions.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/holder_factory.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/lastversion.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/repo_holders/__init__.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/repo_holders/bibucket.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/repo_holders/feed.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/repo_holders/gitea.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/repo_holders/gitlab.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/repo_holders/helmchat.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/repo_holders/local.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/repo_holders/mercurial.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/repo_holders/pypi.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/repo_holders/sourceforge.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/repo_holders/system.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/repo_holders/test.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/repo_holders/wikipedia.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/repo_holders/wordpress.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/spdx_id_to_rpmspec.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/utils.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion/version.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion.egg-info/SOURCES.txt +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion.egg-info/dependency_links.txt +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion.egg-info/entry_points.txt +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion.egg-info/not-zip-safe +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion.egg-info/requires.txt +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/src/lastversion.egg-info/top_level.txt +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/tests/test_cli.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/tests/test_gitea.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/tests/test_github.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/tests/test_hg.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/tests/test_lastversion.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/tests/test_pypi.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/tests/test_sf.py +0 -0
- {lastversion-3.5.3 → lastversion-3.5.4}/tests/test_wiki.py +0 -0
|
@@ -88,6 +88,7 @@ class BaseProjectHolder(requests.Session):
|
|
|
88
88
|
|
|
89
89
|
# Instance of project holder itself uniquely identifies a project (noname)
|
|
90
90
|
REPO_IS_HOLDER = False
|
|
91
|
+
DEFAULT_TIMEOUT = 30 # default timeout in seconds
|
|
91
92
|
|
|
92
93
|
@property
|
|
93
94
|
def name(self):
|
|
@@ -120,7 +121,7 @@ class BaseProjectHolder(requests.Session):
|
|
|
120
121
|
self.hostname = hostname
|
|
121
122
|
if not self.hostname and self.DEFAULT_HOSTNAME:
|
|
122
123
|
self.hostname = self.DEFAULT_HOSTNAME
|
|
123
|
-
# identifies project on a given hostname
|
|
124
|
+
# identifies a project on a given hostname
|
|
124
125
|
# normalize repo to number of meaningful parameters
|
|
125
126
|
self.repo = self.get_base_repo_from_repo_arg(name)
|
|
126
127
|
# in some case we do not specify repo, but feed is discovered; no repo is given then
|
|
@@ -128,6 +129,11 @@ class BaseProjectHolder(requests.Session):
|
|
|
128
129
|
self.even = False
|
|
129
130
|
self.formal = False
|
|
130
131
|
|
|
132
|
+
def request(self, *args, **kwargs):
|
|
133
|
+
"""Set default timeout for requests."""
|
|
134
|
+
kwargs.setdefault("timeout", self.DEFAULT_TIMEOUT)
|
|
135
|
+
return super().request(*args, **kwargs)
|
|
136
|
+
|
|
131
137
|
def get_name_cache(self):
|
|
132
138
|
"""Return name cache from file."""
|
|
133
139
|
if not os.path.exists(self.names_cache_filename):
|
|
@@ -228,7 +234,7 @@ class BaseProjectHolder(requests.Session):
|
|
|
228
234
|
return repo_arg
|
|
229
235
|
if not repo_arg and cls.REPO_URL_PROJECT_COMPONENTS > 0:
|
|
230
236
|
raise ValueError(
|
|
231
|
-
f"Repo arg {repo_arg} does not have
|
|
237
|
+
f"Repo arg {repo_arg} does not have enough URI components ({cls.REPO_URL_PROJECT_COMPONENTS}) for {cls.__name__}"
|
|
232
238
|
)
|
|
233
239
|
if cls.REPO_URL_PROJECT_COMPONENTS >= 1:
|
|
234
240
|
repo_components = repo_arg.split("/")
|
|
@@ -301,7 +307,7 @@ class BaseProjectHolder(requests.Session):
|
|
|
301
307
|
"""
|
|
302
308
|
log.info("Sanitizing string %s as a satisfying version.", version_s)
|
|
303
309
|
|
|
304
|
-
# for libssh2-x.x.x should remove project name prefix to prevent `2` going into the version
|
|
310
|
+
# for `libssh2-x.x.x` should remove project name prefix to prevent `2` going into the version
|
|
305
311
|
prefix = f"{self.name}-"
|
|
306
312
|
if version_s.startswith(prefix):
|
|
307
313
|
version_s = version_s[len(prefix) :]
|
|
@@ -265,80 +265,120 @@ class GitHubRepoSession(BaseProjectHolder):
|
|
|
265
265
|
return None
|
|
266
266
|
|
|
267
267
|
def find_in_tags_via_graphql(self, ret, pre_ok, major):
|
|
268
|
+
"""GraphQL allows for faster search across many tags.
|
|
269
|
+
We aggregate the highest semantic version among batches of 100 records.
|
|
270
|
+
In this way --major filtering results in much fewer requests compared to traditional API
|
|
271
|
+
use.
|
|
272
|
+
|
|
273
|
+
Args:
|
|
274
|
+
ret (dict): currently selected release object
|
|
275
|
+
pre_ok (bool): whether betas are acceptable
|
|
276
|
+
major (str): the major filter
|
|
277
|
+
|
|
278
|
+
Returns: currently selected release object
|
|
279
|
+
|
|
280
|
+
"""
|
|
268
281
|
query_fmt = """
|
|
269
|
-
|
|
282
|
+
{
|
|
270
283
|
rateLimit {
|
|
271
284
|
cost
|
|
272
285
|
remaining
|
|
273
286
|
}
|
|
274
|
-
repository(owner:
|
|
275
|
-
tags: refs(refPrefix: "refs/tags/", first: 100, after:
|
|
287
|
+
repository(owner: "%s", name: "%s") {
|
|
288
|
+
tags: refs(refPrefix: "refs/tags/", first: 100, after: "%s",
|
|
289
|
+
orderBy: {field: TAG_COMMIT_DATE, direction: DESC}) {
|
|
276
290
|
edges {
|
|
277
|
-
cursor
|
|
291
|
+
cursor,
|
|
278
292
|
node {
|
|
279
|
-
|
|
280
|
-
target {
|
|
281
|
-
... on Commit {
|
|
282
|
-
author {
|
|
283
|
-
date
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
... on Tag {
|
|
287
|
-
tagger {
|
|
288
|
-
date
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
293
|
+
...refInfo
|
|
292
294
|
}
|
|
293
295
|
}
|
|
294
296
|
}
|
|
295
297
|
}
|
|
296
298
|
}
|
|
297
|
-
"""
|
|
298
299
|
|
|
300
|
+
fragment refInfo on Ref {
|
|
301
|
+
name
|
|
302
|
+
target {
|
|
303
|
+
sha: oid
|
|
304
|
+
commitResourcePath
|
|
305
|
+
__typename
|
|
306
|
+
... on Tag {
|
|
307
|
+
target {
|
|
308
|
+
... on Commit {
|
|
309
|
+
...commitInfo
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
tagger {
|
|
313
|
+
name
|
|
314
|
+
email
|
|
315
|
+
date
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
... on Commit {
|
|
319
|
+
...commitInfo
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
fragment commitInfo on Commit {
|
|
325
|
+
zipballUrl
|
|
326
|
+
tarballUrl
|
|
327
|
+
author {
|
|
328
|
+
name
|
|
329
|
+
email
|
|
330
|
+
date
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
"""
|
|
299
335
|
cursor = ""
|
|
300
336
|
log.info("Using graphql queries...")
|
|
301
|
-
owner, name = self.repo.split("/")
|
|
302
337
|
while True:
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
)
|
|
338
|
+
# testing on php/php-src
|
|
339
|
+
owner, name = self.repo.split("/")
|
|
340
|
+
query = query_fmt % (owner, name, cursor)
|
|
341
|
+
log.info("Running query %s", query)
|
|
342
|
+
r = self.post(f"{self.api_base}/graphql", json={"query": query})
|
|
308
343
|
log.info('Requested graphql with cursor "%s"', cursor)
|
|
309
|
-
if
|
|
310
|
-
log.info(
|
|
311
|
-
"Query returned non-200 response code %s", response.status_code
|
|
312
|
-
)
|
|
344
|
+
if r.status_code != 200:
|
|
345
|
+
log.info("query returned non 200 response code %s", r.status_code)
|
|
313
346
|
return ret
|
|
314
|
-
|
|
315
|
-
if "errors" in
|
|
347
|
+
j = r.json()
|
|
348
|
+
if "errors" in j and j["errors"][0].get("type") == "NOT_FOUND":
|
|
316
349
|
raise BadProjectError(f"No such project found on GitHub: {self.repo}")
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
log.info("No tags in GraphQL response: %s", response.text)
|
|
350
|
+
if not j["data"]["repository"]["tags"]["edges"]:
|
|
351
|
+
log.info("No tags in GraphQL response: %s", r.text)
|
|
320
352
|
break
|
|
321
|
-
for edge in edges:
|
|
353
|
+
for edge in j["data"]["repository"]["tags"]["edges"]:
|
|
322
354
|
node = edge["node"]
|
|
323
355
|
cursor = edge["cursor"]
|
|
324
356
|
tag_name = node["name"]
|
|
325
357
|
version = self.sanitize_version(tag_name, pre_ok, major)
|
|
326
358
|
if not version:
|
|
327
359
|
continue
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
node["target"]["tagger"]["date"]
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
360
|
+
if "tagger" in node["target"]:
|
|
361
|
+
# use date of annotated tag as it better corresponds to
|
|
362
|
+
# "release date"
|
|
363
|
+
d = node["target"]["tagger"]["date"]
|
|
364
|
+
log.info("Using annotated tag date %s", d)
|
|
365
|
+
else:
|
|
366
|
+
# using commit date because the tag is not annotated
|
|
367
|
+
d = node["target"]["author"]["date"]
|
|
368
|
+
log.info("Using commit date %s", d)
|
|
369
|
+
tag_date = parser.parse(d)
|
|
335
370
|
if ret and tag_date + timedelta(days=365) < ret["tag_date"]:
|
|
336
371
|
log.info("The version %s is newer, but is too old!", version)
|
|
337
372
|
break
|
|
338
|
-
if
|
|
373
|
+
if (
|
|
374
|
+
not ret
|
|
375
|
+
or version >= ret["version"]
|
|
376
|
+
or (tag_date - ret["tag_date"]) > timedelta(hours=1)
|
|
377
|
+
):
|
|
339
378
|
# we always want to return formal release if it exists,
|
|
340
379
|
# because it has useful data grab formal release via APi
|
|
341
|
-
# to check for pre-release
|
|
380
|
+
# to check for pre-release
|
|
381
|
+
# >= case is when we have release from atom but update with tag date from API
|
|
342
382
|
formal_release = self.get_formal_release_for_tag(tag_name)
|
|
343
383
|
if formal_release:
|
|
344
384
|
ret = self.set_matching_formal_release(
|
|
@@ -352,6 +392,9 @@ class GitHubRepoSession(BaseProjectHolder):
|
|
|
352
392
|
"version": version,
|
|
353
393
|
"type": "graphql",
|
|
354
394
|
}
|
|
395
|
+
log.info(
|
|
396
|
+
"Selected version as current selection: %s.", version
|
|
397
|
+
)
|
|
355
398
|
if ret:
|
|
356
399
|
break
|
|
357
400
|
return ret
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Test GitLab support."""
|
|
2
|
+
|
|
2
3
|
import os
|
|
3
4
|
|
|
4
5
|
from packaging import version
|
|
@@ -24,7 +25,7 @@ def test_gitlab_format_json():
|
|
|
24
25
|
|
|
25
26
|
v = latest(repo, output_format="dict")
|
|
26
27
|
|
|
27
|
-
assert "tag_date" in v and v["tag_date"].day ==
|
|
28
|
+
assert "tag_date" in v and v["tag_date"].day == 22
|
|
28
29
|
|
|
29
30
|
|
|
30
31
|
def test_gitlab_at():
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|