|
1 | 1 | (ns repo-analyzer.analyze |
2 | 2 | (:import (java.time LocalDateTime)) |
3 | | - (:require [clojure.tools.logging :as log]) |
| 3 | + (:require [clojure.tools.logging :as log] |
| 4 | + [clojure.string :as string] |
| 5 | + ) |
4 | 6 | ) |
5 | 7 |
|
6 | 8 | (use 'clj-jgit.porcelain) |
|
121 | 123 | ) |
122 | 124 | )) |
123 | 125 |
|
| 126 | +(defn compute-commit-message-length-ranking |
| 127 | + "Computes a ranking regarding the length of the commit messages" |
| 128 | + [logs] |
| 129 | + (->> logs |
| 130 | + (map #(hash-map :message (:msg %) :length (count (:msg %)) :author (get-in % [:author :email]))) |
| 131 | + (sort-by :length #(compare %2 %1)) |
| 132 | + ) |
| 133 | + ) |
| 134 | + |
124 | 135 | (defn compute-commit-statistics |
125 | 136 | "Computes overall commit statistics" |
126 | 137 | [logs] |
|
131 | 142 | committed-by-different-dev (filter #(not (= (:name (:author %)) (:name (:committer %)))) logs) |
132 | 143 | commit-statistics |
133 | 144 | { |
134 | | - :commits logs |
135 | | - :count (count logs) |
136 | | - :self-committed { |
137 | | - :commits self-committed-commits |
138 | | - :count (count self-committed-commits) |
139 | | - :percentage (* 100 (double (/ (count self-committed-commits) (count logs)))) |
140 | | - } |
141 | | - :committed-by-different-dev { |
142 | | - :commits committed-by-different-dev |
143 | | - :count (count committed-by-different-dev) |
144 | | - :percentage (* 100 (double (/ (count committed-by-different-dev) (count logs)))) |
145 | | - } |
146 | | - :time-distribution (compute-commit-time-distribution logs) |
| 145 | + :commits logs |
| 146 | + :count (count logs) |
| 147 | + :self-committed { |
| 148 | + :commits self-committed-commits |
| 149 | + :count (count self-committed-commits) |
| 150 | + :percentage (* 100 (double (/ (count self-committed-commits) (count logs)))) |
| 151 | + } |
| 152 | + :committed-by-different-dev { |
| 153 | + :commits committed-by-different-dev |
| 154 | + :count (count committed-by-different-dev) |
| 155 | + :percentage (* 100 (double (/ (count committed-by-different-dev) (count logs)))) |
| 156 | + } |
| 157 | + :time-distribution (compute-commit-time-distribution logs) |
| 158 | + :commit-message-length-ranking (compute-commit-message-length-ranking logs) |
147 | 159 | } |
148 | 160 | ] |
149 | 161 | (log/info "Computation of commit statistics finished") |
|
0 commit comments