Skip to content

Commit 5eac998

Browse files
committed
i sailuh#302 Adds identity matching to git CLI config
The CLI configuration (e.g. kaialu_cli.yml) now has a section for git exec. This section allows to specify whether developer identities should be matched or not. It also offers a configuration option to match identities by names only. Signed-off-by: Nicole Hoess <[email protected]>
1 parent 7ead48c commit 5eac998

File tree

2 files changed

+64
-35
lines changed

2 files changed

+64
-35
lines changed

conf/kaiaulu_cli.yml

+10
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@
2626
# If you have questions, please open a discussion:
2727
# https://github.com/sailuh/kaiaulu/discussions
2828

29+
30+
# Options for the git CLI.
31+
git:
32+
identity:
33+
# Should identities be matched when parsing the gitlog?
34+
match: TRUE
35+
# Should identities be matched based on names or e-mail-addresses?
36+
names_only: FALSE
37+
38+
# Options for the graph CLI.
2939
graph:
3040
bipartite:
3141
# When creating bipartite networks, you can choose between different

exec/git.R

+54-35
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ require(doSNOW,quietly=TRUE)
2323
doc <- "
2424
USAGE:
2525
git.R tabulate help
26-
git.R tabulate <tools.yml> <project_conf.yml> <save_file_name_path>
26+
git.R tabulate <tools.yml> <project_conf.yml> <cli_conf.yml> <save_file_name_path>
2727
git.R entity help
28-
git.R entity <tools.yml> <project_conf.yml> <gitlog_file_name_path> <save_file_name_path>
28+
git.R entity <tools.yml> <project_conf.yml> <cli_conf.yml> <gitlog_file_name_path> <save_file_name_path>
2929
git.R entity parallel help
30-
git.R entity parallel <tools.yml> <project_conf.yml> <gitlog_file_name_path> <save_folder_name_path>
30+
git.R entity parallel <tools.yml> <project_conf.yml> <cli_conf.yml> <gitlog_file_name_path> <save_folder_name_path>
3131
git.R (-h | --help)
3232
git.R --version
3333
@@ -46,16 +46,21 @@ OPTIONS:
4646

4747
arguments <- docopt::docopt(doc, version = 'Kaiaulu 0.0.0.9600')
4848
if(arguments[["tabulate"]] & arguments[["help"]]){
49-
cli_alert_info("Tabulates a git log using parse_gitlog() and matches
50-
developer identities using identity_match().")
49+
cli_alert_info("Tabulates a git log using parse_gitlog(). Optionally filters
50+
files and matches identities according to the configuration.")
5151
}else if(arguments[["tabulate"]]){
5252

5353
tools_path <- arguments[["<tools.yml>"]]
5454
conf_path <- arguments[["<project_conf.yml>"]]
55+
cli_path <- arguments[["<cli_conf.yml>"]]
5556
save_path <- arguments[["<save_file_name_path>"]]
5657

5758
tool <- yaml::read_yaml(tools_path)
5859
conf <- yaml::read_yaml(conf_path)
60+
cli <- yaml::read_yaml(cli_path)
61+
62+
id_match <- cli[["git"]][["identity"]][["match"]]
63+
id_names_only <- cli[["git"]][["identity"]][["names_only"]]
5964

6065
perceval_path <- path.expand(tool[["perceval"]])
6166
git_repo_path <- path.expand(conf[["version_control"]][["log"]])
@@ -72,33 +77,40 @@ if(arguments[["tabulate"]] & arguments[["help"]]){
7277
if (length(filter_commit_size) > 0) project_git <- project_git %>% filter_by_commit_size(commit_size = filter_commit_size)
7378

7479
# Identity match
75-
project_log <- list(project_git=project_git)
76-
project_log <- identity_match(project_log,
77-
name_column = c("author_name_email"),
78-
assign_exact_identity,
79-
use_name_only=TRUE,
80-
label = "raw_name"
81-
)
82-
project_git <- project_log[["project_git"]]
80+
if (id_match){
81+
project_log <- list(project_git=project_git)
82+
project_log <- identity_match(project_log,
83+
name_column = c("author_name_email"),
84+
assign_exact_identity,
85+
use_name_only=id_names_only,
86+
label = "raw_name")
87+
project_git <- project_log[["project_git"]]
88+
}
8389

8490
data.table::fwrite(project_git,save_path)
8591
cli_alert_success(paste0("Tabulated git log was saved at: ",save_path))
8692
}else if(arguments[["entity"]] & arguments[["parallel"]] & arguments[["help"]]){
8793
cli_alert_info("Parses changed entities using parse_gitlog_entity() in
8894
parallel when analysing multiple time windows. Time
89-
windows are preferentially determined based on ranges
95+
windows are preferentially determined by ranges
9096
specified in the configuration file. If no ranges are
9197
specified, time windows are generated based on the
9298
window size in days starting at the first commit's date.
93-
Also matches developer identities using identity_match().")
99+
Optionally filters files and matches identities according to
100+
the configuration.")
94101
}else if(arguments[["entity"]] & arguments[["parallel"]]){
95102
tools_path <- arguments[["<tools.yml>"]]
96103
conf_path <- arguments[["<project_conf.yml>"]]
104+
cli_path <- arguments[["<cli_conf.yml>"]]
97105
gitlog_path <- arguments[["<gitlog_file_name_path>"]]
98106
save_path <- arguments[["<save_folder_name_path>"]]
99107

100108
tool <- yaml::read_yaml(tools_path)
101109
conf <- yaml::read_yaml(conf_path)
110+
cli <- yaml::read_yaml(cli_path)
111+
112+
id_match <- cli[["git"]][["identity"]][["match"]]
113+
id_names_only <- cli[["git"]][["identity"]][["names_only"]]
102114

103115
# 3rd Party Tools
104116
utags_path <- tool[["utags"]]
@@ -225,17 +237,18 @@ if(arguments[["tabulate"]] & arguments[["help"]]){
225237
origin="1970-01-01",tz = "UTC"),
226238
changed_entities$entity_definition_name,
227239
changed_entities$n_lines_changed
228-
)]
240+
)]
229241

230242
# Identity match
231-
project_log <- list(project_git=changed_entities)
232-
project_log <- identity_match(project_log,
233-
name_column = c("author_name_email"),
234-
assign_exact_identity,
235-
use_name_only=TRUE,
236-
label = "raw_name"
237-
)
238-
changed_entities <- project_log[["project_git"]]
243+
if (id_match){
244+
project_log <- list(project_git=changed_entities)
245+
project_log <- identity_match(project_log,
246+
name_column = c("author_name_email"),
247+
assign_exact_identity,
248+
use_name_only=id_names_only,
249+
label = "raw_name")
250+
changed_entities <- project_log[["project_git"]]
251+
}
239252
}
240253
}
241254
data.table::fwrite(changed_entities,entity_save_path)
@@ -246,16 +259,22 @@ if(arguments[["tabulate"]] & arguments[["help"]]){
246259

247260
cli_alert_success(paste0("Changed entities were saved at: ", save_path))
248261
}else if(arguments[["entity"]] & arguments[["help"]]){
249-
cli_alert_info("Parses changed entities using parse_gitlog_entity() and
250-
matches developer identities using identity_match().")
262+
cli_alert_info("Parses changed entities using parse_gitlog_entity().
263+
Optionally filters files and matches identities according to
264+
the configuration.")
251265
}else if(arguments[["entity"]]){
252266
tools_path <- arguments[["<tools.yml>"]]
253267
conf_path <- arguments[["<project_conf.yml>"]]
268+
cli_path <- arguments[["<cli_conf.yml>"]]
254269
gitlog_path <- arguments[["<gitlog_file_name_path>"]]
255270
save_path <- arguments[["<save_file_name_path>"]]
256271

257272
tool <- yaml::read_yaml(tools_path)
258273
conf <- yaml::read_yaml(conf_path)
274+
cli <- yaml::read_yaml(cli_path)
275+
276+
id_match <- cli[["git"]][["identity"]][["match"]]
277+
id_names_only <- cli[["git"]][["identity"]][["names_only"]]
259278

260279
# 3rd Party Tools
261280
utags_path <- tool[["utags"]]
@@ -285,17 +304,17 @@ if(arguments[["tabulate"]] & arguments[["help"]]){
285304
format = "%a %b %d %H:%M:%S %Y %z", tz = "UTC")
286305

287306
changed_entities <- parse_gitlog_entity(git_repo_path,utags_path,project_git,kinds,progress_bar=TRUE)
288-
data.table::fwrite(changed_entities,save_path)
289307

290308
# Identity match
291-
project_log <- list(project_git=changed_entities)
292-
project_log <- identity_match(project_log,
293-
name_column = c("author_name_email"),
294-
assign_exact_identity,
295-
use_name_only=TRUE,
296-
label = "raw_name"
297-
)
298-
changed_entities <- project_log[["project_git"]]
309+
if (id_match){
310+
project_log <- list(project_git=changed_entities)
311+
project_log <- identity_match(project_log,
312+
name_column = c("author_name_email"),
313+
assign_exact_identity,
314+
use_name_only=id_names_only,
315+
label = "raw_name")
316+
changed_entities <- project_log[["project_git"]]
317+
}
299318

300319
data.table::fwrite(changed_entities,save_path)
301320
cli_alert_success(paste0("Changed entities were saved at: ", save_path))

0 commit comments

Comments
 (0)