assayo 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/assayo +72 -0
- data/bin/assayo.rb +54 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b42f60eed1af650a55273f4a235d47067576d613cdc3c8450816860dff312197
|
4
|
+
data.tar.gz: 6b81c022e074a2c04bb2da9f99f7b1a0c51e252d70145d61d7b05795d0b250ab
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0130fd0cac3352b02a15b8fab6bbc795095d8c97f69ac001eaa4c2930876efe596c6c7db70ba5f76b50bb8ef84b1f15a46688157c8712995bfc1bf9b5e009645
|
7
|
+
data.tar.gz: e394aa696f28e16d71066211b340cf2d020b0665d8c688e2484971c29a255108ebdda8976a330cc881369a6d56d5aec37c89adbd441e79323574227735332c22
|
data/bin/assayo
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/env php
|
2
|
+
<?php
|
3
|
+
|
4
|
+
function logMessage($message) {
|
5
|
+
global $argv;
|
6
|
+
if (in_array('--debug', $argv)) {
|
7
|
+
echo "Assayo: $message\n";
|
8
|
+
}
|
9
|
+
}
|
10
|
+
|
11
|
+
function getErrorMessage($error) {
|
12
|
+
if (!is_object($error) || $error === null) {
|
13
|
+
return strval($error);
|
14
|
+
}
|
15
|
+
if (method_exists($error, 'getTraceAsString')) {
|
16
|
+
return $error->getTraceAsString();
|
17
|
+
}
|
18
|
+
return print_r($error, true);
|
19
|
+
}
|
20
|
+
|
21
|
+
function onFatalError($error) {
|
22
|
+
http_response_code(500);
|
23
|
+
$message = getErrorMessage($error) ?? 'error';
|
24
|
+
fwrite(STDERR, "Assayo: $message\n");
|
25
|
+
exit(2);
|
26
|
+
}
|
27
|
+
|
28
|
+
function getSaveLogCommand($fileName) {
|
29
|
+
global $argv;
|
30
|
+
$raw = in_array('--no-file', $argv) ? '' : '--raw --numstat';
|
31
|
+
return "git --no-pager log $raw --oneline --all --reverse --date=iso-strict --pretty=format:\"%ad>%aN>%aE>%s\" > $fileName";
|
32
|
+
}
|
33
|
+
|
34
|
+
try {
|
35
|
+
// folder, when library was saved
|
36
|
+
$SOURCE_DIR = 'assayo';
|
37
|
+
$SOURCE_PATH = __DIR__ . DIRECTORY_SEPARATOR. '..';
|
38
|
+
|
39
|
+
// folder, when user run library
|
40
|
+
$DIST_DIR = 'assayo';
|
41
|
+
$DIST_PATH = getcwd();
|
42
|
+
|
43
|
+
// 1. Copy folder ./assayo from package to ./assayo in project
|
44
|
+
$source = realpath($SOURCE_PATH . DIRECTORY_SEPARATOR . $SOURCE_DIR);
|
45
|
+
$target = $DIST_PATH . DIRECTORY_SEPARATOR . $DIST_DIR;
|
46
|
+
|
47
|
+
$copyCommand = "cp -r $source $target";
|
48
|
+
exec($copyCommand, $output, $returnVar);
|
49
|
+
if ($returnVar !== 0) {
|
50
|
+
throw new Exception("Failed to copy directory. Command: $copyCommand");
|
51
|
+
}
|
52
|
+
logMessage('directory with HTML report was created');
|
53
|
+
|
54
|
+
// 2. Run "git log" and save output in file ./assayo/log.txt
|
55
|
+
logMessage('reading git log started');
|
56
|
+
$fileName = $DIST_PATH . DIRECTORY_SEPARATOR . $DIST_DIR . DIRECTORY_SEPARATOR . 'log.txt';
|
57
|
+
$logCommand = getSaveLogCommand($fileName);
|
58
|
+
|
59
|
+
exec($logCommand, $output, $returnVar);
|
60
|
+
if ($returnVar !== 0) {
|
61
|
+
throw new Exception("Failed to run git log. Command: $logCommand");
|
62
|
+
}
|
63
|
+
logMessage('the file with git log was saved');
|
64
|
+
|
65
|
+
// 3. Replace symbols in ./assayo/log.txt
|
66
|
+
$content = file_get_contents($fileName);
|
67
|
+
$content = preg_replace(['/\`/m', '/\n/m'], ['', '`);' . PHP_EOL . 'r(f`'], $content);
|
68
|
+
file_put_contents($fileName, "r(f`$content`);");
|
69
|
+
|
70
|
+
} catch (Throwable $error) {
|
71
|
+
onFatalError($error);
|
72
|
+
}
|
data/bin/assayo.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
def get_save_log_command(fileName)
|
4
|
+
raw = "--raw --numstat"
|
5
|
+
if ARGV.include?('--no-file')
|
6
|
+
raw = ""
|
7
|
+
end
|
8
|
+
return "git --no-pager log #{raw} --oneline --all --reverse --date=iso-strict --pretty=format:\"%ad>%aN>%aE>%s\" > #{fileName}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def show_message(message)
|
12
|
+
if ARGV.include?('--debug')
|
13
|
+
puts "Assayo: #{message}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_report()
|
18
|
+
# folder, when library was saved
|
19
|
+
SOURCE_DIR = 'assayo'
|
20
|
+
SOURCE_PATH = Dir.pwd
|
21
|
+
|
22
|
+
# folder, when user run library
|
23
|
+
DIST_DIR = 'assayo'
|
24
|
+
DIST_PATH = Process.cwd
|
25
|
+
|
26
|
+
# 1. Copy folder ./assayo from package to ./assayo in project
|
27
|
+
source = File.join(SOURCE_PATH, SOURCE_DIR)
|
28
|
+
target = File.join(DIST_PATH, DIST_DIR)
|
29
|
+
copy_cmd = "cp -r #{source} #{target}"
|
30
|
+
begin
|
31
|
+
system(copy_cmd)
|
32
|
+
rescue => e
|
33
|
+
puts "Assayo: cant copy files: #{e.message}"
|
34
|
+
end
|
35
|
+
show_message("directory with HTML report was be created")
|
36
|
+
|
37
|
+
# Run "git log" and save output in file ./assayo/log.txt
|
38
|
+
show_message("reading git log was be started")
|
39
|
+
fileName = File.join(Dir.pwd, DIST_DIR, 'log.txt')
|
40
|
+
save_log_cmd = get_save_log_command(fileName)
|
41
|
+
begin
|
42
|
+
system(save_log_cmd)
|
43
|
+
rescue => e
|
44
|
+
puts "Assayo: cant create log file: #{e.message}"
|
45
|
+
end
|
46
|
+
show_message("the file with git log was be saved")
|
47
|
+
|
48
|
+
# 3. Replace symbols in ./assayo/log.txt
|
49
|
+
content = File.read(filename, 'UTF-8').gsub(/`/, '')
|
50
|
+
content = content.gsub(/\n/, '`);\nr(f`')
|
51
|
+
File.open(filename, 'w') { |file| file.write("r(f\`#{content}\`);") }
|
52
|
+
end
|
53
|
+
|
54
|
+
create_report()
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: assayo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aleksei Bakhirev
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-09-27 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Visualization and analysis of git commit statistics. Team Lead performance
|
14
|
+
tool.
|
15
|
+
email: alexey-bakhirev@yandex.ru
|
16
|
+
executables:
|
17
|
+
- assayo
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- bin/assayo
|
22
|
+
- bin/assayo.rb
|
23
|
+
homepage: https://github.com/bakhirev/assayo
|
24
|
+
licenses:
|
25
|
+
- MIT
|
26
|
+
metadata: {}
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubygems_version: 3.5.16
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Assayo
|
46
|
+
test_files: []
|