Loading gitlab_butler/butler.py +5 −4 Original line number Diff line number Diff line Loading @@ -9,7 +9,8 @@ import yaml from gitlab import ( Gitlab, GitlabDeleteError, GitlabGetError, GitlabHttpError, GitlabGetError, GitlabHttpError, ) from gitlab.v4.objects import Group, Project, ProjectFile, ProjectPipeline Loading Loading @@ -342,12 +343,12 @@ class Butler: kept_pipelines: dict[str, list[ProjectPipeline]] = {} # iterate over project pipelines (starting with oldest) for pipeline in project.pipelines.list(iterator=True, sort="asc"): # if the pipeline has been updated after the cutoff date, it is always kept for pipeline in project.pipelines.list(iterator=True, sort="asc", order_by="updated_at"): # if the pipeline has been updated after the cutoff date: keep and break loop if datetime.strptime(pipeline.updated_at, "%Y-%m-%dT%H:%M:%S.%fZ") >= updated_limit: if self.verbose and self.debug: print( f'Pipeline {pipeline.id} age is under limit ({datetime.strptime(pipeline.updated_at, "%Y-%m-%dT%H:%M:%S.%fZ")} >= {updated_limit}), skipping') f'Pipeline {pipeline.id} age is under limit ({datetime.strptime(pipeline.created_at, "%Y-%m-%dT%H:%M:%S.%fZ")} >= {updated_limit}), stopping') break # check pipeline source status Loading tests/test_groups.py +1 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ def mock_empty_project(project_id, archived: bool = False): responses.add(responses.GET, f'http://gitlab.test/api/v4/projects/{project_id}/repository/files/.butlercfg.yml?ref=main', status=404) responses.add(responses.GET, f'http://gitlab.test/api/v4/projects/{project_id}/repository/branches?per_page=100', status=200, json=[]) responses.add(responses.GET, f'http://gitlab.test/api/v4/projects/{project_id}/repository/tags?per_page=100', status=200, json=[]) responses.add(responses.GET, f'http://gitlab.test/api/v4/projects/{project_id}/pipelines?sort=asc&per_page=100', status=200, json=[]) responses.add(responses.GET, f'http://gitlab.test/api/v4/projects/{project_id}/pipelines?sort=asc&order_by=updated_at&per_page=100', status=200, json=[]) class TestGroups: Loading Loading
gitlab_butler/butler.py +5 −4 Original line number Diff line number Diff line Loading @@ -9,7 +9,8 @@ import yaml from gitlab import ( Gitlab, GitlabDeleteError, GitlabGetError, GitlabHttpError, GitlabGetError, GitlabHttpError, ) from gitlab.v4.objects import Group, Project, ProjectFile, ProjectPipeline Loading Loading @@ -342,12 +343,12 @@ class Butler: kept_pipelines: dict[str, list[ProjectPipeline]] = {} # iterate over project pipelines (starting with oldest) for pipeline in project.pipelines.list(iterator=True, sort="asc"): # if the pipeline has been updated after the cutoff date, it is always kept for pipeline in project.pipelines.list(iterator=True, sort="asc", order_by="updated_at"): # if the pipeline has been updated after the cutoff date: keep and break loop if datetime.strptime(pipeline.updated_at, "%Y-%m-%dT%H:%M:%S.%fZ") >= updated_limit: if self.verbose and self.debug: print( f'Pipeline {pipeline.id} age is under limit ({datetime.strptime(pipeline.updated_at, "%Y-%m-%dT%H:%M:%S.%fZ")} >= {updated_limit}), skipping') f'Pipeline {pipeline.id} age is under limit ({datetime.strptime(pipeline.created_at, "%Y-%m-%dT%H:%M:%S.%fZ")} >= {updated_limit}), stopping') break # check pipeline source status Loading
tests/test_groups.py +1 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ def mock_empty_project(project_id, archived: bool = False): responses.add(responses.GET, f'http://gitlab.test/api/v4/projects/{project_id}/repository/files/.butlercfg.yml?ref=main', status=404) responses.add(responses.GET, f'http://gitlab.test/api/v4/projects/{project_id}/repository/branches?per_page=100', status=200, json=[]) responses.add(responses.GET, f'http://gitlab.test/api/v4/projects/{project_id}/repository/tags?per_page=100', status=200, json=[]) responses.add(responses.GET, f'http://gitlab.test/api/v4/projects/{project_id}/pipelines?sort=asc&per_page=100', status=200, json=[]) responses.add(responses.GET, f'http://gitlab.test/api/v4/projects/{project_id}/pipelines?sort=asc&order_by=updated_at&per_page=100', status=200, json=[]) class TestGroups: Loading