mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-06 21:45:43 +01:00
map nonFastForwardDisallowed field from GitConfig and added ui
This commit is contained in:
@@ -15,6 +15,8 @@ public class GitConfigDto extends HalRepresentation {
|
||||
|
||||
private String gcExpression;
|
||||
|
||||
private boolean nonFastForwardDisallowed;
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("squid:S1185") // We want to have this method available in this package
|
||||
protected HalRepresentation add(Links links) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import { InputField, Checkbox } from "@scm-manager/ui-components";
|
||||
type Configuration = {
|
||||
repositoryDirectory?: string,
|
||||
gcExpression?: string,
|
||||
nonFastForwardDisallowed: boolean,
|
||||
disabled: boolean,
|
||||
_links: Links
|
||||
}
|
||||
@@ -41,7 +42,7 @@ class GitConfigurationForm extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const { gcExpression, disabled } = this.state;
|
||||
const { gcExpression, nonFastForwardDisallowed, disabled } = this.state;
|
||||
const { readOnly, t } = this.props;
|
||||
|
||||
return (
|
||||
@@ -53,6 +54,13 @@ class GitConfigurationForm extends React.Component<Props, State> {
|
||||
onChange={this.handleChange}
|
||||
disabled={readOnly}
|
||||
/>
|
||||
<Checkbox name="nonFastForwardDisallowed"
|
||||
label={t("scm-git-plugin.config.nonFastForwardDisallowed")}
|
||||
helpText={t("scm-git-plugin.config.nonFastForwardDisallowedHelpText")}
|
||||
checked={nonFastForwardDisallowed}
|
||||
onChange={this.handleChange}
|
||||
disabled={readOnly}
|
||||
/>
|
||||
<Checkbox name="disabled"
|
||||
label={t("scm-git-plugin.config.disabled")}
|
||||
helpText={t("scm-git-plugin.config.disabledHelpText")}
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
"title": "Git Configuration",
|
||||
"gcExpression": "GC Cron Expression",
|
||||
"gcExpressionHelpText": "Use Quartz Cron Expressions (SECOND MINUTE HOUR DAYOFMONTH MONTH DAYOFWEEK) to run git gc in intervals.",
|
||||
"nonFastForwardDisallowed": "Disallow Non Fast-Forward",
|
||||
"nonFastForwardDisallowedHelpText": "Reject git pushes which are non fast-forward such as --force.",
|
||||
"disabled": "Disabled",
|
||||
"disabledHelpText": "Enable or disable the Git plugin",
|
||||
"submit": "Submit"
|
||||
|
||||
@@ -6,8 +6,7 @@ import org.mockito.InjectMocks;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import sonia.scm.repository.GitConfig;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class GitConfigDtoToGitConfigMapperTest {
|
||||
@@ -21,12 +20,14 @@ public class GitConfigDtoToGitConfigMapperTest {
|
||||
GitConfig config = mapper.map(dto);
|
||||
assertEquals("express", config.getGcExpression());
|
||||
assertFalse(config.isDisabled());
|
||||
assertTrue(config.isNonFastForwardDisallowed());
|
||||
}
|
||||
|
||||
private GitConfigDto createDefaultDto() {
|
||||
GitConfigDto gitConfigDto = new GitConfigDto();
|
||||
gitConfigDto.setGcExpression("express");
|
||||
gitConfigDto.setDisabled(false);
|
||||
gitConfigDto.setNonFastForwardDisallowed(true);
|
||||
return gitConfigDto;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user