idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
45,400
public function executePlugins ( & $ config , $ stage ) { $ success = true ; $ pluginsToExecute = array ( ) ; if ( array_key_exists ( $ stage , $ config ) && is_array ( $ config [ $ stage ] ) ) { $ pluginsToExecute [ ] = $ config [ $ stage ] ; } $ pluginsToExecute = $ this -> getBranchSpecificPlugins ( $ config , $ sta...
Execute a the appropriate set of plugins for a given build stage .
45,401
protected function getBranchSpecificPlugins ( & $ config , $ stage , $ pluginsToExecute ) { $ build = $ this -> pluginFactory -> getResourceFor ( 'PHPCI\Model\Build' ) ; $ branch = $ build -> getBranch ( ) ; if ( ! isset ( $ config [ 'branch-' . $ branch ] [ $ stage ] ) || ! is_array ( $ config [ 'branch-' . $ branch ]...
Check the config for any plugins specific to the branch we re currently building .
45,402
protected function doExecutePlugins ( & $ plugins , $ stage ) { $ success = true ; foreach ( $ plugins as $ plugin => $ options ) { $ this -> logger -> log ( Lang :: get ( 'running_plugin' , $ plugin ) ) ; $ this -> setPluginStatus ( $ stage , $ plugin , Build :: STATUS_RUNNING ) ; if ( $ this -> executePlugin ( $ plug...
Execute the list of plugins found for a given testing stage .
45,403
public function executePlugin ( $ plugin , $ options ) { if ( strpos ( $ plugin , '\\' ) === false ) { $ class = str_replace ( '_' , ' ' , $ plugin ) ; $ class = ucwords ( $ class ) ; $ class = 'PHPCI\\Plugin\\' . str_replace ( ' ' , '' , $ class ) ; } else { $ class = $ plugin ; } if ( ! class_exists ( $ class ) ) { $...
Executes a given plugin with options and returns the result .
45,404
protected function setPluginStatus ( $ stage , $ plugin , $ status ) { $ summary = $ this -> getBuildSummary ( ) ; if ( ! isset ( $ summary [ $ stage ] [ $ plugin ] ) ) { $ summary [ $ stage ] [ $ plugin ] = array ( ) ; } $ summary [ $ stage ] [ $ plugin ] [ 'status' ] = $ status ; if ( $ status === Build :: STATUS_RUN...
Change the status of a plugin for a given stage .
45,405
private function getBuildSummary ( ) { $ build = $ this -> pluginFactory -> getResourceFor ( 'PHPCI\Model\Build' ) ; $ metas = $ this -> store -> getMeta ( 'plugin-summary' , $ build -> getProjectId ( ) , $ build -> getId ( ) ) ; return isset ( $ metas [ 0 ] [ 'meta_value' ] ) ? $ metas [ 0 ] [ 'meta_value' ] : array (...
Fetch the summary data of the current build .
45,406
private function setBuildSummary ( $ summary ) { $ build = $ this -> pluginFactory -> getResourceFor ( 'PHPCI\Model\Build' ) ; $ this -> store -> setMeta ( $ build -> getProjectId ( ) , $ build -> getId ( ) , 'plugin-summary' , json_encode ( $ summary ) ) ; }
Sets the summary data of the current build .
45,407
public function getErrorsForUpgrade ( $ limit ) { $ query = 'SELECT * FROM build_meta WHERE meta_key IN (\'phpmd-data\', \'phpcs-data\', \'phpdoccheck-data\') ORDER BY id ASC LIMIT :limit' ; $ stmt = Database :: getConnection ( 'read' ) -> prepare ( $ query ) ; $ stmt -> bindValue ...
Only used by an upgrade migration to move errors from build_meta to build_error
45,408
public function index ( ) { $ users = $ this -> userStore -> getWhere ( array ( ) , 1000 , 0 , array ( ) , array ( 'email' => 'ASC' ) ) ; $ this -> view -> users = $ users ; $ this -> layout -> title = Lang :: get ( 'manage_users' ) ; return $ this -> view -> render ( ) ; }
View user list .
45,409
public function add ( ) { $ this -> requireAdmin ( ) ; $ this -> layout -> title = Lang :: get ( 'add_user' ) ; $ method = $ this -> request -> getMethod ( ) ; if ( $ method == 'POST' ) { $ values = $ this -> getParams ( ) ; } else { $ values = array ( ) ; } $ form = $ this -> userForm ( $ values ) ; if ( $ method != '...
Add a user - handles both form and processing .
45,410
public function edit ( $ userId ) { $ this -> requireAdmin ( ) ; $ method = $ this -> request -> getMethod ( ) ; $ user = $ this -> userStore -> getById ( $ userId ) ; if ( empty ( $ user ) ) { throw new NotFoundException ( Lang :: get ( 'user_n_not_found' , $ userId ) ) ; } $ this -> layout -> title = $ user -> getNam...
Edit a user - handles both form and processing .
45,411
public function execute ( ) { $ curdir = getcwd ( ) ; chdir ( $ this -> workingdir ) ; $ phpcsfixer = $ this -> phpci -> findBinary ( 'php-cs-fixer' ) ; $ cmd = $ phpcsfixer . ' fix . %s %s %s' ; $ success = $ this -> phpci -> executeCommand ( $ cmd , $ this -> verbose , $ this -> diff , $ this -> level ) ; chdir ( $ c...
Run PHP CS Fixer .
45,412
public function buildArgs ( $ options ) { if ( isset ( $ options [ 'verbose' ] ) && $ options [ 'verbose' ] ) { $ this -> verbose = ' --verbose' ; } if ( isset ( $ options [ 'diff' ] ) && $ options [ 'diff' ] ) { $ this -> diff = ' --diff' ; } if ( isset ( $ options [ 'level' ] ) && in_array ( $ options [ 'level' ] , $...
Build an args string for PHPCS Fixer .
45,413
public function getStubContent ( ) { $ content = '' ; $ filename = $ this -> getStub ( ) ; if ( $ filename ) { $ content = file_get_contents ( $ this -> getPHPCI ( ) -> buildPath . DIRECTORY_SEPARATOR . $ this -> getStub ( ) ) ; } return $ content ; }
Get stub content for the Phar file .
45,414
public function execute ( ) { $ success = false ; try { $ file = $ this -> getDirectory ( ) . DIRECTORY_SEPARATOR . $ this -> getFilename ( ) ; $ phar = new PHPPhar ( $ file , 0 , $ this -> getFilename ( ) ) ; $ phar -> buildFromDirectory ( $ this -> getPHPCI ( ) -> buildPath , $ this -> getRegExp ( ) ) ; $ stub = $ th...
Run the phar plugin .
45,415
public function executeCommand ( $ args = array ( ) ) { $ this -> lastOutput = array ( ) ; $ command = call_user_func_array ( 'sprintf' , $ args ) ; $ this -> logger -> logDebug ( $ command ) ; if ( $ this -> quiet ) { $ this -> logger -> log ( 'Executing: ' . $ command ) ; } $ status = 0 ; $ descriptorSpec = array ( 0...
Executes shell commands .
45,416
public function findBinary ( $ binary , $ quiet = false ) { $ composerBin = $ this -> getComposerBinDir ( realpath ( $ this -> buildPath ) ) ; if ( is_string ( $ binary ) ) { $ binary = array ( $ binary ) ; } foreach ( $ binary as $ bin ) { $ this -> logger -> log ( Lang :: get ( 'looking_for_binary' , $ bin ) , LogLev...
Find a binary required by a plugin .
45,417
public function getComposerBinDir ( $ path ) { if ( is_dir ( $ path ) ) { $ composer = $ path . '/composer.json' ; if ( is_file ( $ composer ) ) { $ json = json_decode ( file_get_contents ( $ composer ) ) ; if ( isset ( $ json -> config -> { "bin-dir" } ) ) { return $ path . '/' . $ json -> config -> { "bin-dir" } ; } ...
Try to load the composer . json file in the building project If the bin - dir is configured return the full path to it
45,418
protected function tidyLoggedBuildContext ( array $ logRecord ) { if ( isset ( $ logRecord [ 'context' ] [ 'build' ] ) ) { $ build = $ logRecord [ 'context' ] [ 'build' ] ; if ( $ build instanceof Build ) { $ logRecord [ 'context' ] [ 'buildID' ] = $ build -> getId ( ) ; unset ( $ logRecord [ 'context' ] [ 'build' ] ) ...
Removes the build object from the logged record and adds the ID as this is more useful to display .
45,419
public function getLastBuildByStatus ( $ projectId = null , $ status = Build :: STATUS_SUCCESS ) { $ query = 'SELECT * FROM build WHERE project_id = :pid AND status = :status ORDER BY id DESC LIMIT 1' ; $ stmt = Database :: getConnection ( 'read' ) -> prepare ( $ query ) ; $ stmt -> bindValue ( ':pid' , $ projectId ) ;...
Return the latest build for a specific project of a specific build status .
45,420
public function getByProjectAndCommit ( $ projectId , $ commitId ) { $ query = 'SELECT * FROM `build` WHERE `project_id` = :project_id AND `commit_id` = :commit_id' ; $ stmt = Database :: getConnection ( 'read' ) -> prepare ( $ query ) ; $ stmt -> bindValue ( ':project_id' , $ projectId ) ; $ stmt -> bindValue ( ':comm...
Return an array of builds for a given project and commit ID .
45,421
public function getBuildBranches ( $ projectId ) { $ query = 'SELECT DISTINCT `branch` FROM `build` WHERE `project_id` = :project_id' ; $ stmt = Database :: getConnection ( 'read' ) -> prepare ( $ query ) ; $ stmt -> bindValue ( ':project_id' , $ projectId ) ; if ( $ stmt -> execute ( ) ) { $ res = $ stmt -> fetchAll (...
Returns all registered branches for project
45,422
public function getMeta ( $ key , $ projectId , $ buildId = null , $ branch = null , $ numResults = 1 ) { $ query = 'SELECT bm.build_id, bm.meta_key, bm.meta_value FROM build_meta AS bm LEFT JOIN build b ON b.id = bm.build_id WHERE bm.meta_key = :key ...
Return build metadata by key project and optionally build id .
45,423
public function setMeta ( $ projectId , $ buildId , $ key , $ value ) { $ cols = '`project_id`, `build_id`, `meta_key`, `meta_value`' ; $ query = 'REPLACE INTO build_meta (' . $ cols . ') VALUES (:projectId, :buildId, :key, :value)' ; $ stmt = Database :: getConnection ( 'read' ) -> prepare ( $ query ) ; $ stmt -> bind...
Set a metadata value for a given project and build ID .
45,424
protected function sendViaSwiftMailer ( ) { $ factory = new MailerFactory ( $ this -> config -> get ( 'phpci' ) ) ; $ mailer = $ factory -> getSwiftMailerFromConfig ( ) ; $ message = \ Swift_Message :: newInstance ( $ this -> subject ) -> setFrom ( $ this -> getFrom ( ) ) -> setTo ( $ this -> emailTo ) -> setBody ( $ t...
Sends the email using SwiftMailer .
45,425
protected function getFrom ( ) { $ email = $ this -> config -> get ( 'phpci.email_settings.from_address' , self :: DEFAULT_FROM ) ; if ( empty ( $ email ) ) { $ email = self :: DEFAULT_FROM ; } return $ email ; }
Get the from address to use for the email .
45,426
public function makeRequest ( $ url , $ params ) { $ http = new HttpClient ( 'https://api.github.com' ) ; $ res = $ http -> get ( $ url , $ params ) ; return $ res [ 'body' ] ; }
Make a request to the Github API .
45,427
public function makeRecursiveRequest ( $ url , $ params , $ results = array ( ) ) { $ http = new HttpClient ( 'https://api.github.com' ) ; $ res = $ http -> get ( $ url , $ params ) ; foreach ( $ res [ 'body' ] as $ item ) { $ results [ ] = $ item ; } foreach ( $ res [ 'headers' ] as $ header ) { if ( preg_match ( '/^L...
Make all GitHub requests following the Link HTTP headers .
45,428
public function getSwiftMailerFromConfig ( ) { $ encryptionType = $ this -> getMailConfig ( 'smtp_encryption' ) ; if ( $ encryptionType && ! in_array ( $ encryptionType , stream_get_transports ( ) ) ) { $ encryptionType = null ; } $ transport = \ Swift_SmtpTransport :: newInstance ( $ this -> getMailConfig ( 'smtp_addr...
Returns an instance of Swift_Mailer based on the config . s
45,429
public function getMailConfig ( $ configName ) { if ( isset ( $ this -> emailConfig [ $ configName ] ) && $ this -> emailConfig [ $ configName ] != "" ) { return $ this -> emailConfig [ $ configName ] ; } else { switch ( $ configName ) { case 'smtp_address' : return "localhost" ; case 'default_mailto_address' : return ...
Return a specific configuration value by key .
45,430
private static function getInstance ( ) { if ( self :: $ converter === null ) { self :: $ converter = new AnsiToHtmlConverter ( null , false ) ; } return self :: $ converter ; }
Initialize the singleton .
45,431
protected function cloneByHttp ( Builder $ builder , $ cloneTo ) { $ cmd = 'git clone --recursive ' ; $ depth = $ builder -> getConfig ( 'clone_depth' ) ; if ( ! is_null ( $ depth ) ) { $ cmd .= ' --depth ' . intval ( $ depth ) . ' ' ; } $ cmd .= ' -b "%s" "%s" "%s"' ; $ success = $ builder -> executeCommand ( $ cmd , ...
Use an HTTP - based git clone .
45,432
protected function cloneBySsh ( Builder $ builder , $ cloneTo ) { $ cmd = 'git clone --recursive ' ; $ depth = $ builder -> getConfig ( 'clone_depth' ) ; if ( ! is_null ( $ depth ) ) { $ cmd .= ' --depth ' . intval ( $ depth ) . ' ' ; } $ cmd .= ' -b "%s" "%s" "%s"' ; $ success = $ this -> runBySsh ( $ builder , $ clon...
Use an SSH - based git clone .
45,433
protected function postCloneSetup ( Builder $ builder , $ cloneTo ) { $ success = true ; $ commit = $ this -> getCommitId ( ) ; $ chdir = IS_WIN ? 'cd /d "%s"' : 'cd "%s"' ; if ( ! empty ( $ commit ) && $ commit != 'Manual' ) { $ cmd = $ chdir . ' && git checkout %s --quiet' ; $ success = $ builder -> executeCommand ( ...
Handle any post - clone tasks like switching branches .
45,434
protected function writeSshKey ( $ cloneTo ) { $ keyPath = dirname ( $ cloneTo . '/temp' ) ; $ keyFile = $ keyPath . '.key' ; file_put_contents ( $ keyFile , $ this -> getProject ( ) -> getSshPrivateKey ( ) ) ; chmod ( $ keyFile , 0600 ) ; return $ keyFile ; }
Create an SSH key file on disk for this build .
45,435
protected function writeSshWrapper ( $ cloneTo , $ keyFile ) { $ path = dirname ( $ cloneTo . '/temp' ) ; $ wrapperFile = $ path . '.sh' ; $ sshFlags = '-o CheckHostIP=no -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o PasswordAuthentication=no' ; $ script = <<<OUT#!/bin/shssh {$sshFlags} -o IdentityFile={$keyFil...
Create an SSH wrapper script for Git to use to disable host key checking etc .
45,436
protected function getRunningPid ( ) { if ( ! file_exists ( $ this -> pidFilePath ) ) { return ; } $ pid = intval ( trim ( file_get_contents ( $ this -> pidFilePath ) ) ) ; if ( $ this -> processControl -> isRunning ( $ pid , true ) ) { return $ pid ; } unlink ( $ this -> pidFilePath ) ; }
Check if there is a running daemon
45,437
public function execute ( ) { list ( $ ignore , $ standard , $ suffixes ) = $ this -> getFlags ( ) ; $ phpcs = $ this -> phpci -> findBinary ( 'phpcs' ) ; $ this -> phpci -> logExecOutput ( false ) ; $ cmd = $ phpcs . ' --report=json %s %s %s %s %s "%s"' ; $ this -> phpci -> executeCommand ( $ cmd , $ standard , $ suff...
Runs PHP Code Sniffer in a specified directory to a specified standard .
45,438
protected function getFlags ( ) { $ ignore = '' ; if ( count ( $ this -> ignore ) ) { $ ignore = ' --ignore=' . implode ( ',' , $ this -> ignore ) ; } if ( strpos ( $ this -> standard , '/' ) !== false ) { $ standard = ' --standard=' . $ this -> directory . $ this -> standard ; } else { $ standard = ' --standard=' . $ ...
Process options and produce an arguments string for PHPCS .
45,439
protected function processReport ( $ output ) { $ data = json_decode ( trim ( $ output ) , true ) ; if ( ! is_array ( $ data ) ) { $ this -> phpci -> log ( $ output ) ; throw new \ Exception ( PHPCI \ Helper \ Lang :: get ( 'could_not_process_report' ) ) ; } $ errors = $ data [ 'totals' ] [ 'errors' ] ; $ warnings = $ ...
Process the PHPCS output report .
45,440
public function execute ( ) { $ phingExecutable = $ this -> phpci -> findBinary ( 'phing' ) ; $ cmd [ ] = $ phingExecutable . ' -f ' . $ this -> getBuildFilePath ( ) ; if ( $ this -> getPropertyFile ( ) ) { $ cmd [ ] = '-propertyfile ' . $ this -> getPropertyFile ( ) ; } $ cmd [ ] = $ this -> propertiesToString ( ) ; $...
Executes Phing and runs a specified targets
45,441
public function parse ( ) { $ this -> lines = array_map ( 'rtrim' , explode ( "\n" , $ this -> tapString ) ) ; $ this -> lineNumber = 0 ; $ this -> testCount = false ; $ this -> results = array ( ) ; $ header = $ this -> findTapLog ( ) ; $ line = $ this -> nextLine ( ) ; if ( $ line === $ header ) { throw new Exception...
Parse a given TAP format string and return an array of tests and their status .
45,442
protected function findTapLog ( ) { do { $ header = $ this -> nextLine ( ) ; } while ( $ header !== false && substr ( $ header , 0 , 12 ) !== 'TAP version ' ) ; if ( $ header === false ) { throw new Exception ( 'No TAP log found, please check the configuration.' ) ; } elseif ( $ header !== 'TAP version 13' ) { throw ne...
Looks for the start of the TAP log in the string .
45,443
protected function nextLine ( ) { if ( $ this -> lineNumber < count ( $ this -> lines ) ) { return $ this -> lines [ $ this -> lineNumber ++ ] ; } return false ; }
Fetch the next line .
45,444
protected function parseLine ( $ line ) { if ( preg_match ( self :: TEST_DIAGNOSTIC , $ line ) || preg_match ( self :: TEST_COVERAGE , $ line ) || ! $ line ) { return ; } if ( preg_match ( self :: TEST_COUNTS_PATTERN , $ line , $ matches ) ) { $ this -> testCount = intval ( $ matches [ 1 ] ) ; return ; } if ( $ this ->...
Parse a single line .
45,445
protected function processYamlBlock ( $ indent ) { $ startLine = $ this -> lineNumber + 1 ; $ endLine = $ indent . '...' ; $ yamlLines = array ( ) ; do { $ line = $ this -> nextLine ( ) ; if ( $ line === false ) { throw new Exception ( Lang :: get ( 'tap_error_endless_yaml' , $ startLine ) ) ; } elseif ( $ line === $ e...
Process an indented Yaml block .
45,446
protected function processDirective ( $ test , $ directive , $ reason ) { $ test [ 'severity' ] = strtolower ( $ directive ) === 'skip' ? 'skipped' : 'todo' ; if ( ! empty ( $ reason ) ) { if ( ! empty ( $ test [ 'message' ] ) ) { $ test [ 'message' ] .= ', ' . $ test [ 'severity' ] . ': ' ; } $ test [ 'message' ] .= $...
Process a TAP directive
45,447
public static function register ( LoggerInterface $ logger = null ) { $ handler = new static ( $ logger ) ; set_error_handler ( array ( $ handler , 'handleError' ) ) ; register_shutdown_function ( array ( $ handler , 'handleFatalError' ) ) ; set_exception_handler ( array ( $ handler , 'handleException' ) ) ; }
Register a new log handler .
45,448
public function storeMeta ( $ key , $ value ) { $ value = json_encode ( $ value ) ; Factory :: getStore ( 'Build' ) -> setMeta ( $ this -> getProjectId ( ) , $ this -> getId ( ) , $ key , $ value ) ; }
Store build metadata
45,449
protected function getZeroConfigPlugins ( Builder $ builder ) { $ pluginDir = PHPCI_DIR . 'PHPCI/Plugin/' ; $ dir = new \ DirectoryIterator ( $ pluginDir ) ; $ config = array ( 'build_settings' => array ( 'ignore' => array ( 'vendor' , ) ) ) ; foreach ( $ dir as $ item ) { if ( $ item -> isDot ( ) ) { continue ; } if (...
Get an array of plugins to run if there s no phpci . yml file .
45,450
public function getExtra ( $ key = null ) { $ data = json_decode ( $ this -> data [ 'extra' ] , true ) ; if ( is_null ( $ key ) ) { $ rtn = $ data ; } elseif ( isset ( $ data [ $ key ] ) ) { $ rtn = $ data [ $ key ] ; } else { $ rtn = null ; } return $ rtn ; }
Return a value from the build s extra JSON array .
45,451
public function getBuildPath ( ) { if ( ! $ this -> getId ( ) ) { return null ; } if ( empty ( $ this -> currentBuildPath ) ) { $ buildDirectory = $ this -> getId ( ) . '_' . substr ( md5 ( microtime ( true ) ) , 0 , 5 ) ; $ this -> currentBuildPath = PHPCI_BUILD_ROOT_DIR . $ buildDirectory . DIRECTORY_SEPARATOR ; } re...
Return the path to run this build into .
45,452
public function removeBuildDirectory ( ) { $ buildPath = rtrim ( $ this -> getBuildPath ( ) , '/' ) ; if ( ! $ buildPath || ! is_dir ( $ buildPath ) ) { return ; } if ( is_link ( $ buildPath ) ) { exec ( sprintf ( IS_WIN ? 'rmdir /S /Q "%s"' : 'rm "%s"' , $ buildPath ) ) ; } else { exec ( sprintf ( IS_WIN ? 'rmdir /S /...
Removes the build directory .
45,453
public function getDuration ( ) { $ start = $ this -> getStarted ( ) ; if ( empty ( $ start ) ) { return 0 ; } $ end = $ this -> getFinished ( ) ; if ( empty ( $ end ) ) { $ end = new \ DateTime ( ) ; } return $ end -> getTimestamp ( ) - $ start -> getTimestamp ( ) ; }
Get the number of seconds a build has been running for .
45,454
protected function getConfigFormat ( ) { $ conf = $ this -> username ; if ( ! empty ( $ this -> server ) ) { $ conf .= ';' . $ this -> server ; } $ conf .= ' ' . $ this -> password ; if ( ! empty ( $ this -> alias ) ) { $ conf .= ' ' . $ this -> alias ; } return $ conf ; }
Get config format for sendxmpp config file
45,455
public function execute ( ) { $ sendxmpp = $ this -> phpci -> findBinary ( 'sendxmpp' ) ; if ( count ( $ this -> recipients ) == 0 ) { return false ; } $ config_file = $ this -> phpci -> buildPath . DIRECTORY_SEPARATOR . '.sendxmpprc' ; if ( is_null ( $ this -> findConfigFile ( ) ) ) { file_put_contents ( $ config_file...
Send notification message .
45,456
public function log ( $ message , $ level = LogLevel :: INFO , $ context = array ( ) ) { if ( ! $ this -> logger ) { return ; } if ( ! is_array ( $ message ) ) { $ message = array ( $ message ) ; } $ context [ 'build' ] = $ this -> build ; foreach ( $ message as $ item ) { $ this -> logger -> log ( $ level , $ item , $...
Add an entry to the build log .
45,457
public function isRunning ( $ pid ) { $ output = $ exitCode = null ; exec ( sprintf ( "ps %d" , $ pid ) , $ output , $ exitCode ) ; return $ exitCode === 0 ; }
Check process using the ps command .
45,458
public function getCommitMessage ( ) { $ rtn = parent :: getCommitMessage ( $ this -> data [ 'commit_message' ] ) ; $ project = $ this -> getProject ( ) ; if ( ! is_null ( $ project ) ) { $ reference = $ project -> getReference ( ) ; $ commitLink = '<a target="_blank" href="https://github.com/' . $ reference . '/issues...
Get a parsed version of the commit message with links to issues and commits .
45,459
protected function postCloneSetup ( Builder $ builder , $ cloneTo ) { $ buildType = $ this -> getExtra ( 'build_type' ) ; $ success = true ; try { if ( ! empty ( $ buildType ) && $ buildType == 'pull_request' ) { $ remoteUrl = $ this -> getExtra ( 'remote_url' ) ; $ remoteBranch = $ this -> getExtra ( 'remote_branch' )...
Handle any post - clone tasks like applying a pull request patch on top of the branch .
45,460
protected function getDiffLineNumber ( Builder $ builder , $ file , $ line ) { $ line = ( integer ) $ line ; $ builder -> logExecOutput ( false ) ; $ prNumber = $ this -> getExtra ( 'pull_request_number' ) ; $ path = $ builder -> buildPath ; if ( ! empty ( $ prNumber ) ) { $ builder -> executeCommand ( 'cd %s && git di...
Uses git diff to figure out what the diff line position is based on the error line number .
45,461
public function view ( $ projectId ) { $ branch = $ this -> getParam ( 'branch' , '' ) ; $ project = $ this -> projectStore -> getById ( $ projectId ) ; if ( empty ( $ project ) ) { throw new NotFoundException ( Lang :: get ( 'project_x_not_found' , $ projectId ) ) ; } $ per_page = 10 ; $ page = $ this -> getParam ( 'p...
View a specific project .
45,462
public function build ( $ projectId , $ branch = '' ) { $ project = $ this -> projectStore -> getById ( $ projectId ) ; if ( empty ( $ project ) ) { throw new NotFoundException ( Lang :: get ( 'project_x_not_found' , $ projectId ) ) ; } if ( $ branch === '' && filter_input ( INPUT_GET , 'branch' ) !== null ) { $ branch...
Create a new pending build for a project .
45,463
public function builds ( $ projectId ) { $ branch = $ this -> getParam ( 'branch' , '' ) ; $ builds = $ this -> getLatestBuildsHtml ( $ projectId , urldecode ( $ branch ) ) ; $ this -> response -> disableLayout ( ) ; $ this -> response -> setContent ( $ builds [ 0 ] ) ; return $ this -> response ; }
AJAX get latest builds .
45,464
public function add ( ) { $ this -> layout -> title = Lang :: get ( 'add_project' ) ; $ this -> requireAdmin ( ) ; $ method = $ this -> request -> getMethod ( ) ; $ pub = null ; $ values = $ this -> getParams ( ) ; if ( $ method != 'POST' ) { $ sshKey = new SshKey ( ) ; $ key = $ sshKey -> generate ( ) ; $ values [ 'ke...
Add a new project . Handles both the form and processing .
45,465
public function edit ( $ projectId ) { $ this -> requireAdmin ( ) ; $ method = $ this -> request -> getMethod ( ) ; $ project = $ this -> projectStore -> getById ( $ projectId ) ; if ( empty ( $ project ) ) { throw new NotFoundException ( Lang :: get ( 'project_x_not_found' , $ projectId ) ) ; } $ this -> layout -> tit...
Edit a project . Handles both the form and processing .
45,466
protected function getReferenceValidator ( $ values ) { return function ( $ val ) use ( $ values ) { $ type = $ values [ 'type' ] ; $ validators = array ( 'hg' => array ( 'regex' => '/^(https?):\/\//' , 'message' => Lang :: get ( 'error_mercurial' ) ) , 'remote' => array ( 'regex' => '/^(git|https?):\/\//' , 'message' ...
Get the validator to use to check project references .
45,467
protected function findGlobalBinary ( $ binary ) { $ command = sprintf ( 'where %s' , $ binary ) ; $ result = shell_exec ( $ command ) ; return trim ( $ result ) ; }
Use where on Windows to find a binary rather than which
45,468
protected function write ( array $ record ) { $ message = ( string ) $ record [ 'message' ] ; $ message = str_replace ( $ this -> build -> currentBuildPath , '/' , $ message ) ; $ this -> logValue .= $ message . PHP_EOL ; $ this -> build -> setLog ( $ this -> logValue ) ; Factory :: getStore ( 'Build' ) -> save ( $ thi...
Write a log entry to the build log .
45,469
public function createProject ( $ title , $ type , $ reference , $ options = array ( ) ) { $ project = new Project ( ) ; return $ this -> updateProject ( $ project , $ title , $ type , $ reference , $ options ) ; }
Create a new project model and use the project store to save it .
45,470
public function updateProject ( Project $ project , $ title , $ type , $ reference , $ options = array ( ) ) { $ project -> setTitle ( $ title ) ; $ project -> setType ( $ type ) ; $ project -> setReference ( $ reference ) ; $ project -> setAllowPublicStatus ( 0 ) ; if ( array_key_exists ( 'ssh_private_key' , $ options...
Update the properties of a given project .
45,471
protected function processAccessInformation ( Project & $ project ) { $ matches = array ( ) ; $ reference = $ project -> getReference ( ) ; if ( $ project -> getType ( ) == 'gitlab' ) { $ info = array ( ) ; if ( preg_match ( '`^(.+)@(.+):([0-9]*)\/?(.+)\.git`' , $ reference , $ matches ) ) { $ info [ 'user' ] = $ match...
In circumstances where it is necessary populate access information based on other project properties .
45,472
protected function cloneByHttp ( Builder $ builder , $ cloneTo ) { $ cmd = $ this -> svnCommand ; if ( $ this -> getCommitId ( ) != 'Manual' ) { $ cmd .= ' -r %s %s "%s"' ; $ success = $ builder -> executeCommand ( $ cmd , $ this -> getCommitId ( ) , $ this -> getCloneUrl ( ) , $ cloneTo ) ; } else { $ cmd .= ' %s "%s"...
Use an HTTP - based svn export .
45,473
protected function cloneBySsh ( Builder $ builder , $ cloneTo ) { $ cmd = $ this -> svnCommand . ' %s "%s"' ; if ( ! IS_WIN ) { $ keyFile = $ this -> writeSshKey ( $ cloneTo ) ; $ sshWrapper = $ this -> writeSshWrapper ( $ cloneTo , $ keyFile ) ; $ cmd = 'export SVN_SSH="' . $ sshWrapper . '" && ' . $ cmd ; } $ success...
Use an SSH - based svn export .
45,474
public function execute ( ) { $ message = $ this -> phpci -> interpolate ( $ this -> message ) ; $ successfulBuild = $ this -> build -> isSuccessful ( ) ? 'Success' : 'Failed' ; $ push = new Push ( $ this -> api_key ) ; $ flowMessage = TeamInboxMessage :: create ( ) -> setSource ( "PHPCI" ) -> setFromAddress ( $ this -...
Run the Flowdock plugin .
45,475
public function execute ( ) { try { $ opts = array ( PDO :: ATTR_ERRMODE => PDO :: ERRMODE_EXCEPTION ) ; $ pdo = new PDO ( 'mysql:host=' . $ this -> host , $ this -> user , $ this -> pass , $ opts ) ; foreach ( $ this -> queries as $ query ) { if ( ! is_array ( $ query ) ) { $ pdo -> query ( $ this -> phpci -> interpol...
Connects to MySQL and runs a specified set of queries .
45,476
public function execute ( ) { $ msg = $ this -> phpci -> interpolate ( $ this -> message ) ; if ( empty ( $ this -> server ) || empty ( $ this -> room ) || empty ( $ this -> nick ) ) { $ this -> phpci -> logFailure ( Lang :: get ( 'irc_settings' ) ) ; } if ( empty ( $ this -> port ) ) { $ this -> port = 6667 ; } $ sock...
Run IRC plugin .
45,477
protected function wipeExistingDirectory ( ) { if ( $ this -> wipe === true && $ this -> directory != '/' && is_dir ( $ this -> directory ) ) { $ cmd = 'rm -Rf "%s*"' ; $ success = $ this -> phpci -> executeCommand ( $ cmd , $ this -> directory ) ; if ( ! $ success ) { throw new \ Exception ( Lang :: get ( 'failed_to_w...
Wipe the destination directory if it already exists .
45,478
protected function deleteIgnoredFiles ( ) { if ( $ this -> ignore ) { foreach ( $ this -> phpci -> ignore as $ file ) { $ cmd = 'rm -Rf "%s/%s"' ; if ( IS_WIN ) { $ cmd = 'rmdir /S /Q "%s\%s"' ; } $ this -> phpci -> executeCommand ( $ cmd , $ this -> directory , $ file ) ; } } }
Delete any ignored files from the build prior to copying .
45,479
public function getSeverityString ( ) { switch ( $ this -> getSeverity ( ) ) { case self :: SEVERITY_CRITICAL : return 'critical' ; case self :: SEVERITY_HIGH : return 'high' ; case self :: SEVERITY_NORMAL : return 'normal' ; case self :: SEVERITY_LOW : return 'low' ; } }
Get the language string key for this error s severity level .
45,480
public function getSeverityClass ( ) { switch ( $ this -> getSeverity ( ) ) { case self :: SEVERITY_CRITICAL : return 'danger' ; case self :: SEVERITY_HIGH : return 'warning' ; case self :: SEVERITY_NORMAL : return 'info' ; case self :: SEVERITY_LOW : return 'default' ; } }
Get the class to apply to HTML elements representing this error .
45,481
protected function runConfigFile ( $ configPath ) { $ this -> phpci -> logExecOutput ( false ) ; $ codecept = $ this -> phpci -> findBinary ( 'codecept' ) ; if ( ! $ codecept ) { $ this -> phpci -> logFailure ( Lang :: get ( 'could_not_find' , 'codecept' ) ) ; return false ; } $ cmd = 'cd "%s" && ' . $ codecept . ' run...
Run tests from a Codeception config file .
45,482
public function index ( ) { $ this -> requireAdmin ( ) ; $ json = $ this -> getComposerJson ( ) ; $ this -> view -> installedPackages = $ json [ 'require' ] ; $ pluginInfo = new PluginInformationCollection ( ) ; $ pluginInfo -> add ( FilesPluginInformation :: newFromDir ( PHPCI_DIR . "PHPCI/Plugin/" ) ) ; $ pluginInfo ...
List all enabled plugins installed and recommend packages .
45,483
public function init ( ) { $ request = & $ this -> request ; $ route = '/:controller/:action' ; $ opts = array ( 'controller' => 'Home' , 'action' => 'index' ) ; $ validateSession = function ( ) { if ( ! empty ( $ _SESSION [ 'phpci_user_id' ] ) ) { $ user = b8 \ Store \ Factory :: getStore ( 'User' ) -> getByPrimaryKey...
Initialise PHPCI - Handles session verification routing etc .
45,484
public function handleRequest ( ) { try { $ this -> response = parent :: handleRequest ( ) ; } catch ( HttpException $ ex ) { $ this -> config -> set ( 'page_title' , 'Error' ) ; $ view = new View ( 'exception' ) ; $ view -> exception = $ ex ; $ this -> response -> setResponseCode ( $ ex -> getErrorCode ( ) ) ; $ this ...
Handle an incoming web request .
45,485
protected function loadController ( $ class ) { $ controller = parent :: loadController ( $ class ) ; $ controller -> layout = new View ( 'layout' ) ; $ controller -> layout -> title = 'PHPCI' ; $ controller -> layout -> breadcrumb = array ( ) ; return $ controller ; }
Loads a particular controller and injects our layout view into it .
45,486
protected function setLayoutVariables ( View & $ layout ) { $ groups = array ( ) ; $ groupStore = b8 \ Store \ Factory :: getStore ( 'ProjectGroup' ) ; $ groupList = $ groupStore -> getWhere ( array ( ) , 100 , 0 , array ( ) , array ( 'title' => 'ASC' ) ) ; foreach ( $ groupList [ 'items' ] as $ group ) { $ thisGroup =...
Injects variables into the layout before rendering it .
45,487
public function view ( $ buildId ) { try { $ build = BuildFactory :: getBuildById ( $ buildId ) ; } catch ( \ Exception $ ex ) { $ build = null ; } if ( empty ( $ build ) ) { throw new NotFoundException ( Lang :: get ( 'build_x_not_found' , $ buildId ) ) ; } $ this -> view -> plugins = $ this -> getUiPlugins ( ) ; $ th...
View a specific build .
45,488
protected function getUiPlugins ( ) { $ rtn = array ( ) ; $ path = APPLICATION_PATH . 'public/assets/js/build-plugins/' ; $ dir = opendir ( $ path ) ; while ( $ item = readdir ( $ dir ) ) { if ( substr ( $ item , 0 , 1 ) == '.' || substr ( $ item , - 3 ) != '.js' ) { continue ; } $ rtn [ ] = $ item ; } return $ rtn ; }
Returns an array of the JS plugins to include .
45,489
public function delete ( $ buildId ) { $ this -> requireAdmin ( ) ; $ build = BuildFactory :: getBuildById ( $ buildId ) ; if ( empty ( $ build ) ) { throw new NotFoundException ( Lang :: get ( 'build_x_not_found' , $ buildId ) ) ; } $ this -> buildService -> deleteBuild ( $ build ) ; $ response = new b8 \ Http \ Respo...
Delete a build .
45,490
protected function formatBuilds ( $ builds ) { Project :: $ sleepable = array ( 'id' , 'title' , 'reference' , 'type' ) ; $ rtn = array ( 'count' => $ builds [ 'count' ] , 'items' => array ( ) ) ; foreach ( $ builds [ 'items' ] as $ build ) { $ item = $ build -> toArray ( 1 ) ; $ header = new b8 \ View ( 'Build/header-...
Formats a list of builds into rows suitable for the dropdowns in the PHPCI header bar .
45,491
public function execute ( ) { $ buildPath = $ this -> phpci -> buildPath ; if ( ! array_key_exists ( $ this -> build -> getBranch ( ) , $ this -> actions ) ) { return true ; } $ curdir = getcwd ( ) ; chdir ( $ buildPath ) ; $ success = true ; foreach ( $ this -> actions [ $ this -> build -> getBranch ( ) ] as $ action ...
Run the Git plugin .
45,492
protected function runAction ( $ action , array $ options = array ( ) ) { switch ( $ action ) { case 'merge' : return $ this -> runMergeAction ( $ options ) ; case 'tag' : return $ this -> runTagAction ( $ options ) ; case 'pull' : return $ this -> runPullAction ( $ options ) ; case 'push' : return $ this -> runPushAct...
Determine which action to run and run it .
45,493
protected function runMergeAction ( $ options ) { if ( array_key_exists ( 'branch' , $ options ) ) { $ cmd = 'cd "%s" && git checkout %s && git merge "%s"' ; $ path = $ this -> phpci -> buildPath ; return $ this -> phpci -> executeCommand ( $ cmd , $ path , $ options [ 'branch' ] , $ this -> build -> getBranch ( ) ) ; ...
Handle a merge action .
45,494
protected function runTagAction ( $ options ) { $ tagName = date ( 'Ymd-His' ) ; $ message = Lang :: get ( 'tag_created' , date ( 'Y-m-d H:i:s' ) ) ; if ( array_key_exists ( 'name' , $ options ) ) { $ tagName = $ this -> phpci -> interpolate ( $ options [ 'name' ] ) ; } if ( array_key_exists ( 'message' , $ options ) )...
Handle a tag action .
45,495
protected function runPullAction ( $ options ) { $ branch = $ this -> build -> getBranch ( ) ; $ remote = 'origin' ; if ( array_key_exists ( 'branch' , $ options ) ) { $ branch = $ this -> phpci -> interpolate ( $ options [ 'branch' ] ) ; } if ( array_key_exists ( 'remote' , $ options ) ) { $ remote = $ this -> phpci -...
Handle a pull action .
45,496
protected function reportErrors ( $ output ) { foreach ( $ output as $ error ) { $ message = 'Class ' . $ error [ 'class' ] . ' is missing a docblock.' ; $ severity = PHPCI \ Model \ BuildError :: SEVERITY_LOW ; if ( $ error [ 'type' ] == 'method' ) { $ message = $ error [ 'class' ] . '::' . $ error [ 'method' ] . ' is...
Report all of the errors we ve encountered line - by - line .
45,497
protected function execute ( InputInterface $ input , OutputInterface $ output ) { $ this -> configFilePath = $ input -> getOption ( 'config-path' ) ; if ( ! $ this -> verifyNotInstalled ( $ output ) ) { return ; } $ output -> writeln ( '' ) ; $ output -> writeln ( '<info>******************</info>' ) ; $ output -> writ...
Installs PHPCI - Can be run more than once as long as you ^C instead of entering an email address .
45,498
protected function checkRequirements ( OutputInterface $ output ) { $ output -> write ( 'Checking requirements...' ) ; $ errors = false ; if ( ! ( version_compare ( PHP_VERSION , '5.3.8' ) >= 0 ) ) { $ output -> writeln ( '' ) ; $ output -> writeln ( '<error>' . Lang :: get ( 'phpci_php_req' ) . '</error>' ) ; $ errors...
Check PHP version required modules and for disabled functions .
45,499
protected function getAdminInformation ( InputInterface $ input , OutputInterface $ output ) { $ admin = array ( ) ; $ dialog = $ this -> getHelperSet ( ) -> get ( 'dialog' ) ; $ mailValidator = function ( $ answer ) { if ( ! filter_var ( $ answer , FILTER_VALIDATE_EMAIL ) ) { throw new \ InvalidArgumentException ( Lan...
Load information for admin user form CLI options or ask info to user .