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