Skip to content

Commit 4a419d6

Browse files
committed
added include_deps to remote action plugin protontypes#164
1 parent 31601a4 commit 4a419d6

File tree

2 files changed

+47
-30
lines changed

2 files changed

+47
-30
lines changed

libreselery/contribution_action_plugins/github_remote_contributors_action.py

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def initialize_(self, action):
5353
init = True
5454
self.uniform_score = action.readParam("uniform_score")
5555
self.min_contributions = action.readParam("min_contributions", default=0)
56+
self.include_deps = action.readParam("include_dependencies", default=False)
5657
init = False if not self.uniform_score or not self.min_contributions else True
5758
return init
5859

@@ -112,34 +113,14 @@ def gather_(self, cachedContributors=[]):
112113
"Gathering project information of '%s' at local folder '%s"
113114
% (projectUrl, self.directory)
114115
)
115-
116116
if self.include_main_repository:
117-
#### find official repositories
118-
self.log(
119-
"Including contributors of root project '%s'"
120-
% localProject.full_name
121-
)
122-
123-
self.log(" -- %s" % localProject.html_url)
124-
# print(" -- %s" % [c.author.email for c in localContributors])
125-
126-
### grab contributors
127-
remoteContributors = self.githubConnector.grabRemoteProjectContributors(
128-
localProject
129-
)
130-
### filter contributors
131-
remoteContributors = self.validateContributors(remoteContributors)
132-
### extract relevant contributor information from the guthub api
133-
for c in remoteContributors:
134-
email = c.stats.author.email.lower()
135-
username = c.stats.author.login
136-
project = c.fromProject
137-
if email and username:
138-
contributors.append(Contributor(username, email, fromProject=project))
139-
### calculate scores of the contributors
140-
### we could dosome fancy stuff here
141-
### but for now, everyone gets uniform "base" score and nothing else
142-
scores = [self.uniform_score for i in range(len(contributors))]
117+
cons, scrs = self.gatherProjectContributors(localProject)
118+
contributors.extend(cons)
119+
scores.extend(scrs)
120+
if self.include_deps:
121+
cons, scrs = self.gatherProjectDeps(localProject)
122+
contributors.extend(cons)
123+
scores.extend(scrs)
143124
else:
144125
self.log(
145126
"Skipping work because no Connector with name '%s' could be found!"
@@ -153,6 +134,38 @@ def gather_(self, cachedContributors=[]):
153134
### specialzed plugin methods can be added here
154135
##################################################################################
155136
###
137+
def gatherProjectContributors(self, project):
138+
contributors = []
139+
#### find official repositories
140+
self.log("Including contributors of root project '%s'" % project.full_name)
141+
self.log(" -- %s" % project.html_url)
142+
# print(" -- %s" % [c.author.email for c in localContributors])
143+
144+
### grab contributors
145+
remoteContributors = self.githubConnector.grabRemoteProjectContributors(project)
146+
### filter contributors
147+
remoteContributors = self.validateContributors(remoteContributors)
148+
### extract relevant contributor information from the guthub api
149+
for c in remoteContributors:
150+
email = c.stats.author.email.lower()
151+
username = c.stats.author.login
152+
project = c.fromProject
153+
if email and username:
154+
contributors.append(Contributor(username, email, fromProject=project))
155+
### calculate scores of the contributors
156+
### we could dosome fancy stuff here
157+
### but for now, everyone gets uniform "base" score and nothing else
158+
scores = [self.uniform_score for i in range(len(contributors))]
159+
return contributors, scores
160+
161+
def gatherProjectDeps(self, project):
162+
contributors = []
163+
scores = []
164+
### do stuff to include deps contributors as well
165+
### ...
166+
self.log("XAXA")
167+
return contributors, scores
168+
156169
def validateContributors(self, contributors):
157170
valid = []
158171
for c in contributors:
@@ -201,6 +214,11 @@ def test():
201214
"contributions_from_github": {
202215
"debug": True,
203216
"type": "github_remote_contributors_action", ### type of action (also the name of the plugin _alias_ used!)
217+
"params": {
218+
"min_contributions": 1,
219+
"uniform_score": 30,
220+
"include_dependencies": True,
221+
},
204222
"metrics": [ ### metrics applied to this action, what gets score and what doesnt
205223
{"UNIFORM": {}} ### metric identifier
206224
],
@@ -222,9 +240,7 @@ def test():
222240
config = LibreSeleryConfig(
223241
{
224242
"directory": os.path.abspath(os.path.join(os.getcwd(), "..", "..")),
225-
"min_contributions_required_payout": 1,
226243
"include_main_repository": True,
227-
"uniform_score": 30,
228244
}
229245
)
230246
action.updateGlobals(config=config, connectors=connectors)

libreselery/contribution_distribution_engine_types.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ def __hash__(self):
6868

6969
### boolean operators for this object to make it fit for dict use
7070
def __eq__(self, other):
71-
#return (self.username, self.email) == (other.username, other.email)
71+
# return (self.username, self.email) == (other.username, other.email)
7272
return self.email == other.email
73+
7374
def __ne__(self, other):
7475
return not (self == other)
7576

0 commit comments

Comments
 (0)