-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option to order results by last commit date #37
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import json | ||
from types import MethodType | ||
|
||
import requests | ||
from IGitt.GitLab.GitLab import GitLabPrivateToken | ||
|
@@ -22,6 +23,9 @@ def __init__(self, token, group, **kargs): | |
self._token = GitLabPrivateToken(token) | ||
self._org = GitLabOrganization(self._token, self._group) | ||
|
||
for repo in self._org.repositories: | ||
repo.get_last_commit_date = MethodType(_get_last_commit_date, repo) | ||
|
||
self._status_provider = self.StatusProvider(self._group) | ||
|
||
@classmethod | ||
|
@@ -39,8 +43,19 @@ def process_repository(self, repo, branch='master'): | |
self.HostName, | ||
branch=branch) | ||
|
||
return RepoStatus(repo.web_url, repo_status) | ||
last_commit_date = repo.get_last_commit_date() | ||
|
||
return RepoStatus(repo.web_url, repo_status, last_commit_date) | ||
|
||
@property | ||
def repositories(self): | ||
return self._org.repositories | ||
|
||
|
||
def _get_last_commit_date(self): | ||
repo_commit_dates = [''] | ||
for commit in self.commits: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, this will not work with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why iterate over every commit? That is horribly inefficient. Any list of commits should be already pre-sorted, most recent first, so you should be able to get only the first using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there is a problem in the GitLabRepository implementation, that needs to be solved upstream in IGitt. If so, add a comment here in this PR explaining the problem, and we'll check and you can create an issue and solve the IGitt bug. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the list of commits is not pre-sorted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, we'll get IGitt fixed so this doesnt need to be so ugly. |
||
repo_commit_dates.append(commit.data._data['committed_date']) | ||
repo_commit_dates.sort() | ||
|
||
return repo_commit_dates[-1] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ git+https://gitlab.com/gitmate/open-source/IGitt.git#egg=IGitt | |
requests | ||
termcolor | ||
giturlparse | ||
pyyaml | ||
gitman |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
https://github.com/foo/r0: passing (last commit: 2018-11-05T08:20:37Z) | ||
https://github.com/foo/r1: passing (last commit: 2018-11-02T17:31:46Z) | ||
https://github.com/foo/r2: passing (last commit: 2018-11-06T02:27:42Z) | ||
0 Passing, 0 Failing, 0 Error, 0 Unknown of 3 Repositories |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
https://github.com/foo/r2: passing (last commit: 2018-11-06T02:27:42Z) | ||
https://github.com/foo/r0: passing (last commit: 2018-11-05T08:20:37Z) | ||
https://github.com/foo/r1: passing (last commit: 2018-11-02T17:31:46Z) | ||
0 Passing, 0 Failing, 0 Error, 0 Unknown of 3 Repositories |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like how you are patching in a method here. We already have support for Gitman and once your #34 gets merged we will support
--use-repo-list
. This method will work when the merge happens.At this point of time, we have two ways to address this problem.
OrgHost
to get the commit dates of a given repo independently.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jayvdb Your thoughts?