File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
core/src/main/java/com/flowci/core/git/controller Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change 44import com .flowci .core .common .domain .GitSource ;
55import com .flowci .core .git .domain .GitConfig ;
66import com .flowci .core .git .service .GitService ;
7+ import com .flowci .exception .ArgumentException ;
78import lombok .extern .log4j .Log4j2 ;
89import org .springframework .beans .factory .annotation .Autowired ;
910import org .springframework .web .bind .annotation .*;
@@ -33,6 +34,10 @@ public GitConfig get(@PathVariable String source) {
3334 @ Action (GitActions .SAVE )
3435 @ PostMapping ()
3536 public GitConfig save (@ RequestBody Request .SaveOptions options ) {
37+ if (options .getSource () == GitSource .GERRIT && options .getHost () == null ) {
38+ throw new ArgumentException ("Host address is required for Gerrit" );
39+ }
40+
3641 return gitService .save (options .toGitConfig ());
3742 }
3843
Original file line number Diff line number Diff line change 22
33import com .flowci .core .common .domain .GitSource ;
44import com .flowci .core .git .domain .GitConfig ;
5+ import com .flowci .core .git .domain .GitConfigWithHost ;
6+ import com .flowci .util .StringHelper ;
57import lombok .Getter ;
68import lombok .Setter ;
79
@@ -17,10 +19,16 @@ public static class SaveOptions {
1719 @ NotNull
1820 private GitSource source ;
1921
22+ private String host ;
23+
2024 @ NotEmpty
2125 private String secret ;
2226
2327 public GitConfig toGitConfig () {
28+ if (StringHelper .hasValue (host )) {
29+ return new GitConfigWithHost (source , secret , host );
30+ }
31+
2432 return new GitConfig (source , secret );
2533 }
2634 }
You can’t perform that action at this time.
0 commit comments