|
| 1 | +import org.codehaus.plexus.util.FileUtils; |
| 2 | + |
| 3 | +try { |
| 4 | + File gitTag = new File(basedir, ".git/refs/tags/0.0.3"); |
| 5 | + if (!gitTag.exists()) { |
| 6 | + System.out.println("release-finish .git/refs/tags/0.0.3 doesn't exist"); |
| 7 | + return false; |
| 8 | + } |
| 9 | + |
| 10 | + File gitReleaseRef = new File(basedir, ".git/refs/heads/release/0.0.3"); |
| 11 | + if (gitReleaseRef.exists()) { |
| 12 | + System.out.println("release-finish .git/refs/heads/release/0.0.3 exists"); |
| 13 | + return false; |
| 14 | + } |
| 15 | + File gitDevelopRef = new File(basedir, ".git/refs/heads/develop"); |
| 16 | + if (!gitDevelopRef.exists()) { |
| 17 | + System.out.println("release-finish .git/refs/heads/develop doesn't exist"); |
| 18 | + return false; |
| 19 | + } |
| 20 | + File gitMasterRef = new File(basedir, ".git/refs/heads/master"); |
| 21 | + if (!gitMasterRef.exists()) { |
| 22 | + System.out.println("release-finish .git/refs/heads/master doesn't exist"); |
| 23 | + return false; |
| 24 | + } |
| 25 | + |
| 26 | + File file = new File(basedir, "pom.xml"); |
| 27 | + File expectedFile = new File(basedir, "expected-development-pom.xml"); |
| 28 | + |
| 29 | + String actual = FileUtils.fileRead(file, "UTF-8"); |
| 30 | + String expected = FileUtils.fileRead(expectedFile, "UTF-8"); |
| 31 | + |
| 32 | + actual = actual.replaceAll("\\r?\\n", ""); |
| 33 | + expected = expected.replaceAll("\\r?\\n", ""); |
| 34 | + |
| 35 | + if (!expected.equals(actual)) { |
| 36 | + System.out.println("release-finish expected development pom: " + expected + " actual was:" + actual); |
| 37 | + return false; |
| 38 | + } |
| 39 | + |
| 40 | + p = Runtime.getRuntime().exec("git --git-dir=" + basedir + "/.git --work-tree=" + basedir + " checkout master"); |
| 41 | + p.waitFor(); |
| 42 | + |
| 43 | + file = new File(basedir, "pom.xml"); |
| 44 | + expectedFile = new File(basedir, "expected-production-pom.xml"); |
| 45 | + |
| 46 | + actual = FileUtils.fileRead(file, "UTF-8"); |
| 47 | + expected = FileUtils.fileRead(expectedFile, "UTF-8"); |
| 48 | + |
| 49 | + actual = actual.replaceAll("\\r?\\n", ""); |
| 50 | + expected = expected.replaceAll("\\r?\\n", ""); |
| 51 | + |
| 52 | + if (!expected.equals(actual)) { |
| 53 | + System.out.println("release-finish expected production pom: " + expected + " actual was:" + actual); |
| 54 | + return false; |
| 55 | + } |
| 56 | + |
| 57 | +} catch (Exception e) { |
| 58 | + e.printStackTrace(); |
| 59 | + return false; |
| 60 | +} |
| 61 | +return true; |
0 commit comments