You appear to be a bot. Output may be restricted
Description
List the changed filesIf we're using a git/GitHub repository then we can easily list the changed files by using git commands.
git diff --name_only sha1 sha2
git diff --name_only
oikb_get_git_source() should return the directory of the git repo
use this function in preference to oikb_maybe_do_files()
Note: Having found the git directory we need to stay in this directory in order to parse all the files This also means that the server needs to have the git extract as well!
Usage
oikb_list_changed_files( $prev_version, $plugin, $component_type, $oiksc_parse_status );
Parameters
- $prev_version
- ( string ) required – the previous version – normally an SHA
- $plugin
- ( string ) required – the plugin or theme slug
- $component_type
- ( string ) required –
- $oiksc_parse_status
- ( object ) optional – parse status object
Returns
voidSource
File name: oik-batch/oik-list-previous-files.phpLines:
1 to 56 of 56
function oikb_list_changed_files( $prev_version, $plugin, $component_type, $oiksc_parse_status=null ) { $git_loaded = oik_require_lib( "git" ); if ( $git_loaded && !is_wp_error( $git_loaded ) ) { // Hooray - loaded by oik_require_lib() - that's a bonus } else { oik_require( "libs/oik-git.php", "oik-batch" ); git(); } if ( class_exists( "Git" ) ) { $git = Git(); $source_dir = oikb_source_dir( $plugin, $component_type ); echo "Source dir: $source_dir" . PHP_EOL; $git_dir = oikb_is_git( $source_dir ); if ( !$git_dir ) { $repository = $plugin; $git_dir = oikb_get_git_source( $repository ); } echo "Git dir: $git_dir" . PHP_EOL; if ( $git_dir ) { if ( $prev_version == '0' ) { $files = oikb_git_command( "list" ); } else { $files = oikb_git_command( "changed", $prev_version ); } $files = $git->result_as_array(); //chdir( $git_dir ); } else { $files = null; echo "No Git repo found for $plugin $component_type" . PHP_EOL; } } else { $files = null; } $of_n = count( $files ); if ( $of_n && $oiksc_parse_status ) { echo "GIT changes: " . $of_n . PHP_EOL; $current_sha = oikb_git_command( "current" ); echo "Current SHA: $current_sha" . PHP_EOL; $oiksc_parse_status->set_current_sha( $current_sha ); $oiksc_parse_status->set_current_of_n( $of_n ); $oiksc_parse_status->restart_processing(); //$to_sha = $oiksc_parse_status->get_to_sha(); //if ( !$to_sha ) { // $oiksc_parse_status->set_to_sha( $current_sha ); // $oiksc_parse_status->set_of_n( $of_n ); //} } return( $files ); }View on GitHub