Skip to content

Commit

Permalink
improve discover_files
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Dec 3, 2023
1 parent db750d9 commit 301a3d3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion verify.v
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,20 @@ fn vout(v_file string, output string) !(string, bool) {

fn discover_files() ![]string {
if os.getenv('CHANGED') != '' {
git_diff_cmd := 'git --no-pager diff --name-only FETCH_HEAD'
mut base_ref := 'origin/main'
mut ref := 'HEAD'
if os.getenv('CI') != '' {
base_ref = os.getenv('GITHUB_BASE_REF')
ref = os.getenv('GITHUB_REF')
}
git_diff_cmd := 'git --no-pager diff --name-only ${base_ref} ${ref}'
println(git_diff_cmd)
changes := os.execute(git_diff_cmd).output.split_into_lines()
dump(changes)
files := changes.filter(it.ends_with('.v') && it.starts_with('20'))
if files.len > 0 {
println('running only a subset of all tests, based on the git diff for the new/changed solutions, compared to the main origin branch: ${files}')
flush_stdout()
return files
}
}
Expand Down

0 comments on commit 301a3d3

Please sign in to comment.