Skip to content

Commit

Permalink
Merge pull request #281 from Automattic/updates-relating-to-pr273
Browse files Browse the repository at this point in the history
Small updates: Use new functions introduced in #273; update HTTP wait function; update URL in README.md; update tests
  • Loading branch information
gudmdharalds authored Jul 12, 2022
2 parents 6d0ce30 + 9088745 commit d43ed67
Show file tree
Hide file tree
Showing 17 changed files with 379 additions and 727 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ To get `vip-go-ci` working, follow these steps:
if [ -d ~/vip-go-ci-tools ] ; then
bash ~/vip-go-ci-tools/vip-go-ci/tools-init.sh
else
wget https://raw.githubusercontent.com/Automattic/vip-go-ci/trunk/tools-init.sh -O tools-init.sh && \
wget https://raw.githubusercontent.com/Automattic/vip-go-ci/latest/tools-init.sh -O tools-init.sh && \
bash tools-init.sh && \
rm -f tools-init.sh
fi
Expand Down
92 changes: 38 additions & 54 deletions ap-file-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,67 +37,51 @@ function vipgoci_ap_file_types(
)
);

$prs_implicated = vipgoci_github_prs_implicated(
$options['repo-owner'],
$options['repo-name'],
$commit_skipped_files = array();

$pr_item_files_changed = vipgoci_github_files_affected_by_commit(
$options,
$options['commit'],
$options['token'],
$options['branches-ignore'],
$options['skip-draft-prs']
$commit_skipped_files,
true, // Renamed files included.
true, // Removed files included.
true, // Permission changes included.
null
);

foreach ( $prs_implicated as $pr_item ) {
$pr_diff = vipgoci_git_diffs_fetch(
$options['local-git-repo'],
$options['repo-owner'],
$options['repo-name'],
$options['token'],
$pr_item->base->sha,
$options['commit'],
true, // Renamed files included.
true, // Removed files included.
true, // Permission changes included.
null
);

/*
* Loop through files renamed, removed, had
* permissions changed, or content modified
* -- and auto-approve them if their file-type
* is auto-approvable.
*/
foreach ( $pr_item_files_changed['all'] as $pr_diff_file_name ) {
/*
* Note: We will here loop through files
* that have been renamed, removed, had their
* permission changed, or had their contents
* modified -- and then we might auto-approve
* them (if their file-type is auto-approvable).
* If the file is already in the array
* of approved files, do not do anything.
*/
if ( isset(
$auto_approved_files_arr[ $pr_diff_file_name ]
) ) {
continue;
}

foreach ( $pr_diff['files'] as
$pr_diff_file_name => $pr_diff_contents
) {
/*
* If the file is already in the array
* of approved files, do not do anything.
*/
if ( isset(
$auto_approved_files_arr[ $pr_diff_file_name ]
) ) {
continue;
}

$pr_diff_file_extension = vipgoci_file_extension_get(
$pr_diff_file_name
);
$pr_diff_file_extension = vipgoci_file_extension_get(
$pr_diff_file_name
);

/*
* Check if the extension of the file
* is in a list of auto-approvable
* file extensions.
*/
if ( in_array(
$pr_diff_file_extension,
$options['autoapprove-filetypes'],
true
) ) {
$auto_approved_files_arr[ $pr_diff_file_name ]
= 'autoapprove-filetypes';
}
/*
* Check if the extension of the file
* is in a list of auto-approvable
* file extensions.
*/
if ( in_array(
$pr_diff_file_extension,
$options['autoapprove-filetypes'],
true
) ) {
$auto_approved_files_arr[ $pr_diff_file_name ]
= 'autoapprove-filetypes';
}
}

Expand Down
Loading

0 comments on commit d43ed67

Please sign in to comment.