Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Squash

hotfix_branch = "hotfix/2.34.1"
release_branch = "release/2.35.0"
master_branch = "master"
feature_branch = "1923-core-something"

def check_branch(source_branch, squash)
    is_release_branch = (/^(release\/)(\d+).(\d+).(\d+)$/.match(source_branch))
    is_hotfix_branch = (/^(hotfix\/)(\d+).(\d+).(\d+)$/.match(source_branch))
    is_master_branch = source_branch == "master"
    
    unless squash || is_release_branch || is_hotfix_branch || is_master_branch 
       puts "failed" 
    else
       puts "passed"
    end
end

puts "Hotfix, squash = true => passed"
check_branch(hotfix_branch, true)

puts "Hotfix, squash = false => passed"
check_branch(hotfix_branch, false)

puts "Release, squash = true => passed"
check_branch(release_branch, true)

puts "Release, squash = true => passed"
check_branch(release_branch, false)

puts "Master, squash = true => passed"
check_branch(master_branch, true)

puts "Master, squash = false => passed"
check_branch(master_branch, false)

puts "Feature, squash = true => passed"
check_branch(feature_branch, true)

puts "Feature, squash = false => failed"
check_branch(feature_branch, false)

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.