129 static void print_html_footer() { |
130 static void print_html_footer() { |
130 puts("\t</body>\n</html>"); |
131 puts("\t</body>\n</html>"); |
131 } |
132 } |
132 |
133 |
133 int main(int argc, char *argv[]) { |
134 int main(int argc, char *argv[]) { |
|
135 // parse settings |
134 fm::settings settings; |
136 fm::settings settings; |
135 |
|
136 if (parse_args(settings, argc, argv)) { |
137 if (parse_args(settings, argc, argv)) { |
137 return EXIT_FAILURE; |
138 return EXIT_FAILURE; |
138 } |
139 } |
139 |
140 |
|
141 // check hg and git |
|
142 fm::process proc; |
|
143 proc.setbin(settings.hg); |
|
144 if (proc.exec({"--version"})) { |
|
145 fprintf(stderr, "Testing hg binary '%s' failed!\n", settings.hg.c_str()); |
|
146 return EXIT_FAILURE; |
|
147 } |
|
148 proc.setbin(settings.git); |
|
149 if (proc.exec({"--version"})) { |
|
150 fprintf(stderr, "Testing git binary '%s' failed!\n", settings.git.c_str()); |
|
151 return EXIT_FAILURE; |
|
152 } |
|
153 |
|
154 // scan for repos |
140 fm::repositories repos; |
155 fm::repositories repos; |
141 for (auto &&path: settings.paths) { |
156 for (auto &&path: settings.paths) { |
142 repos.scan(path, settings.depth); |
157 repos.scan(path, settings.depth); |
143 } |
158 } |
144 if (!settings.update_repos) { |
159 |
145 // TODO: update repositories |
160 // update repos, if not disabled |
|
161 if (settings.update_repos) { |
|
162 for (auto &&repo : repos.list()) { |
|
163 proc.chdir(repo.path); |
|
164 if (repo.type == fm::HG) { |
|
165 proc.setbin(settings.hg); |
|
166 if (proc.exec({"pull"})) { |
|
167 fprintf(stderr, "Pulling repo '%s' failed!\nMaybe there is no remote?\n", repo.path.c_str()); |
|
168 } else if (proc.exec({"update"})) { |
|
169 fprintf(stderr, "Updating repo '%s' failed!\nMaybe there are local changes?\n", repo.path.c_str()); |
|
170 } |
|
171 } else { |
|
172 proc.setbin(settings.git); |
|
173 if (proc.exec({"pull"})) { |
|
174 fprintf(stderr, "Pulling repo '%s' failed!\nMaybe there is no remote or there are local changes?\n", repo.path.c_str()); |
|
175 } |
|
176 } |
|
177 } |
146 } |
178 } |
147 // TODO: calculate the heat maps |
179 // TODO: calculate the heat maps |
148 |
180 |
149 print_html_header(); |
181 print_html_header(); |
150 // TODO: output the heat maps here |
182 // TODO: output the heat maps here |