-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_build_filelists
executable file
·83 lines (65 loc) · 2.58 KB
/
generate_build_filelists
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
#
# This script compiles kernel and collects a list of complite-time files and related Git metadata
# for each newly added line from tag 1 to tag 2.
set -e
show_help() {
echo "Usage: ./generate_build_filelists [tag1] [tag2] [clone-path]"
echo "Example: ./generate_build_filelists.h tag1 tag2 clone_path"
echo
echo "Options:"
echo " tag1 Required. old_tag."
echo " tag2 Required. new_tag."
echo " clone_path Requred. the path to clone the linux repo to apply change diff analysis."
echo " -h Display this help message"
exit 0
}
display_file_head() {
local dir_name="$1"
local file_name="$2"
local line_num="$3"
echo "First $line_num lines of $file_name:"
head -n "$line_num" "$dir_name/$file_name"
echo
}
export -f display_file_head
if [[ "$1" == "-h" ]]; then
show_help
fi
# Ensure required arguments (tag1 and tag2) are provided
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
show_help
fi
TAG1="$1"
TAG2="$2"
CLONE_PATH="$3"
SUBSYS="$4"
mkdir -p "build_data"
curr_dir=$(pwd)
echo "$curr_dir"
export curr_dir
export CLONE_PATH
cd "$CLONE_PATH"
bash "$curr_dir"/build_scripts/build_collect_diff "$TAG1" "$TAG2" "$SUBSYS"
echo "Finishing generating build source file lists"
# Fetch email and name pairing information for linux contributor
bash "$curr_dir"/build_scripts/git_shortlog "$TAG2"
display_file_head "$curr_dir/build_data" "name_list.txt" 3
echo "finished generating email and name list"
# Reframe the git diff report for javascript front-end syntax
input_file="$curr_dir/build_data/filtered_diff_header.txt"
output_file="$curr_dir/build_data/filtered_diff_header_replace.txt"
sed 's/\\/\\\\/g' "$input_file" > "$output_file"
display_file_head "$curr_dir/build_data" "filtered_diff_header_replace.txt" 3
input_file="$curr_dir/build_data/filtered_diff_source.txt"
output_file="$curr_dir/build_data/filtered_diff_source_replace.txt"
sed 's/\\/\\\\/g' "$input_file" > "$output_file"
display_file_head "$curr_dir/build_data" "filtered_diff_source_replace.txt" 3
# Retrieve and tokenize commit info per added line
echo "tokenizing each commit line ..."
git checkout "$TAG2"
"$curr_dir"/build_scripts/tokenize "$curr_dir/build_data/filtered_diff_header.txt" "$curr_dir/build_data/tokenize_header.json" "$TAG1" "$TAG2"
"$curr_dir"/build_scripts/tokenize "$curr_dir/build_data/filtered_diff_source.txt" "$curr_dir/build_data/tokenize_source.json" "$TAG1" "$TAG2"
display_file_head "$curr_dir/build_data" "tokenize_source.json" 3
display_file_head "$curr_dir/build_data" "tokenize_header.json" 3
echo "finished tokenization"