Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Heroku |
|
| 1.0;1 |
1 | 2 | /** |
2 | * Copyright (c) 2012-2014, jcabi.com | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: 1) Redistributions of source code must retain the above | |
8 | * copyright notice, this list of conditions and the following | |
9 | * disclaimer. 2) Redistributions in binary form must reproduce the above | |
10 | * copyright notice, this list of conditions and the following | |
11 | * disclaimer in the documentation and/or other materials provided | |
12 | * with the distribution. 3) Neither the name of the jcabi.com nor | |
13 | * the names of its contributors may be used to endorse or promote | |
14 | * products derived from this software without specific prior written | |
15 | * permission. | |
16 | * | |
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT | |
19 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
20 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | |
21 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
28 | * OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 | */ | |
30 | package com.jcabi.heroku.maven.plugin; | |
31 | ||
32 | import com.jcabi.aspects.Immutable; | |
33 | import com.jcabi.log.Logger; | |
34 | import java.io.File; | |
35 | import javax.validation.constraints.NotNull; | |
36 | import lombok.EqualsAndHashCode; | |
37 | import lombok.ToString; | |
38 | ||
39 | /** | |
40 | * Heroku platform. | |
41 | * | |
42 | * @author Yegor Bugayenko (yegor@tpc2.com) | |
43 | * @version $Id$ | |
44 | * @since 0.4 | |
45 | */ | |
46 | @Immutable | |
47 | 0 | @ToString |
48 | 0 | @EqualsAndHashCode(of = { "git", "name" }) |
49 | final class Heroku { | |
50 | ||
51 | /** | |
52 | * Git engine. | |
53 | */ | |
54 | private final transient Git git; | |
55 | ||
56 | /** | |
57 | * Project name in Heroku. | |
58 | */ | |
59 | private final transient String name; | |
60 | ||
61 | /** | |
62 | * Public ctor. | |
63 | * @param engine Git engine | |
64 | * @param project Project name in Heroku | |
65 | */ | |
66 | 1 | public Heroku(@NotNull final Git engine, @NotNull final String project) { |
67 | 1 | this.git = engine; |
68 | 1 | this.name = project; |
69 | 1 | } |
70 | ||
71 | /** | |
72 | * Clone repo into local copy. | |
73 | * @param path Where to copy | |
74 | * @return The repo | |
75 | */ | |
76 | public Repo clone(@NotNull final File path) { | |
77 | 1 | this.git.exec( |
78 | path.getParentFile(), | |
79 | "clone", | |
80 | "--verbose", | |
81 | String.format("git@heroku.com:%s.git", this.name), | |
82 | path.getAbsolutePath() | |
83 | ); | |
84 | 0 | Logger.info( |
85 | this, | |
86 | "Heroku Git repository '%s' cloned into %s", | |
87 | this.name, | |
88 | path | |
89 | ); | |
90 | 0 | this.git.exec( |
91 | path, | |
92 | // @checkstyle MultipleStringLiterals (1 line) | |
93 | "config", | |
94 | "user.name", | |
95 | "jcabi-heroku-maven-plugin" | |
96 | ); | |
97 | 0 | this.git.exec( |
98 | path, | |
99 | "config", | |
100 | "user.email", | |
101 | "no-reply@jcabi.com" | |
102 | ); | |
103 | 0 | return new Repo(this.git, path); |
104 | } | |
105 | ||
106 | } |