All files sync.js

92.86% Statements 26/28
87.5% Branches 7/8
66.67% Functions 2/3
92.86% Lines 26/28

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 493x   3x 3x 3x     55x 55x 55x 164x       55x 55x 6x 6x 6x     49x 49x 49x   5x 5x 5x     44x 46x     44x 44x 44x   44x                 3x  
const core              = require( '@actions/core' )
 
const handleIssues          = require( './ghIssuesHandling' )
const handleSubtask         = require( './jiraSubtaskHandling' )
const handleSync            = require( './jiraUpdate' )
 
async function syncJiraWithGH() {
    try {
        const useSubtaskMode = core.getInput( 'SUBTASK_MODE' ) === 'true'
        const DEBUG = core.getInput( 'DEBUG_MODE' ) === 'true'
                      ? ( messageToLog ) => ( console.log( `<<<<DEBUG----------------\n${ JSON.stringify( messageToLog ) }\n----------------DEBUG>>>>` ) )
                      : () => {}
    
    
        const issueEventTriggered = await handleIssues( useSubtaskMode, DEBUG )
        if( !issueEventTriggered ) {
            console.log( `--! no change to be handled` )
            console.log( 'Ending Action' )
            return
        }
    
        const subtasksOrIssuesToUpdate = await handleSubtask( issueEventTriggered, useSubtaskMode, DEBUG )
        DEBUG( subtasksOrIssuesToUpdate )
        if( !subtasksOrIssuesToUpdate
            || subtasksOrIssuesToUpdate.length === 0 ) {
            console.log( `--! no subtask or issue to upgrade found at all` )
            console.log( 'Ending Action' )
            return
        }
    
        for( const currentSubtaskOrIssue of subtasksOrIssuesToUpdate ) {
            await handleSync( currentSubtaskOrIssue, issueEventTriggered, DEBUG )
        }
        
        console.log( `==> action success` )
        console.log( `Action Finished` )
        core.setOutput('time', new Date().toTimeString() )
        
        return 0
    } catch ( error ) {
        core.setFailed( error.message )
        return 1
    }
}
 
 
 
module.exports.syncJiraWithGH = syncJiraWithGH