mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-12-21 15:59:48 +01:00
Add new default branch option with 'main' as default
This commit is contained in:
committed by
René Pfeuffer
parent
b48bf24834
commit
196ea227d2
@@ -41,6 +41,8 @@ public class GitConfigDto extends HalRepresentation {
|
|||||||
|
|
||||||
private boolean nonFastForwardDisallowed;
|
private boolean nonFastForwardDisallowed;
|
||||||
|
|
||||||
|
private String defaultBranch;
|
||||||
|
|
||||||
@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) {
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||||||
import javax.xml.bind.annotation.XmlTransient;
|
import javax.xml.bind.annotation.XmlTransient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(name = "config")
|
@XmlRootElement(name = "config")
|
||||||
@@ -49,6 +48,9 @@ public class GitConfig extends RepositoryConfig {
|
|||||||
@XmlElement(name = "disallow-non-fast-forward")
|
@XmlElement(name = "disallow-non-fast-forward")
|
||||||
private boolean nonFastForwardDisallowed;
|
private boolean nonFastForwardDisallowed;
|
||||||
|
|
||||||
|
@XmlElement(name = "default-branch")
|
||||||
|
private String defaultBranch = "main";
|
||||||
|
|
||||||
public String getGcExpression() {
|
public String getGcExpression() {
|
||||||
return gcExpression;
|
return gcExpression;
|
||||||
}
|
}
|
||||||
@@ -65,6 +67,14 @@ public class GitConfig extends RepositoryConfig {
|
|||||||
this.nonFastForwardDisallowed = nonFastForwardDisallowed;
|
this.nonFastForwardDisallowed = nonFastForwardDisallowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDefaultBranch() {
|
||||||
|
return defaultBranch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultBranch(String defaultBranch) {
|
||||||
|
this.defaultBranch = defaultBranch;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@XmlTransient // Only for permission checks, don't serialize to XML
|
@XmlTransient // Only for permission checks, don't serialize to XML
|
||||||
public String getId() {
|
public String getId() {
|
||||||
|
|||||||
@@ -24,12 +24,13 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { WithTranslation, withTranslation } from "react-i18next";
|
import { WithTranslation, withTranslation } from "react-i18next";
|
||||||
import { Links } from "@scm-manager/ui-types";
|
import { Links } from "@scm-manager/ui-types";
|
||||||
import { InputField, Checkbox } from "@scm-manager/ui-components";
|
import { InputField, Checkbox, validation as validator } from "@scm-manager/ui-components";
|
||||||
|
|
||||||
type Configuration = {
|
type Configuration = {
|
||||||
repositoryDirectory?: string;
|
repositoryDirectory?: string;
|
||||||
gcExpression?: string;
|
gcExpression?: string;
|
||||||
nonFastForwardDisallowed: boolean;
|
nonFastForwardDisallowed: boolean;
|
||||||
|
defaultBranch: string;
|
||||||
_links: Links;
|
_links: Links;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -68,8 +69,21 @@ class GitConfigurationForm extends React.Component<Props, State> {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onDefaultBranchChange = (value: string) => {
|
||||||
|
this.setState(
|
||||||
|
{
|
||||||
|
defaultBranch: value
|
||||||
|
},
|
||||||
|
() => this.props.onConfigurationChange(this.state, this.isValidDefaultBranch())
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
isValidDefaultBranch = () => {
|
||||||
|
return validator.isNameValid(this.state.defaultBranch);
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { gcExpression, nonFastForwardDisallowed } = this.state;
|
const { gcExpression, nonFastForwardDisallowed, defaultBranch } = this.state;
|
||||||
const { readOnly, t } = this.props;
|
const { readOnly, t } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -90,6 +104,15 @@ class GitConfigurationForm extends React.Component<Props, State> {
|
|||||||
onChange={this.onNonFastForwardDisallowed}
|
onChange={this.onNonFastForwardDisallowed}
|
||||||
disabled={readOnly}
|
disabled={readOnly}
|
||||||
/>
|
/>
|
||||||
|
<InputField
|
||||||
|
name="defaultBranch"
|
||||||
|
label={t("scm-git-plugin.config.defaultBranch")}
|
||||||
|
value={defaultBranch}
|
||||||
|
onChange={this.onDefaultBranchChange}
|
||||||
|
disabled={readOnly}
|
||||||
|
validationError={!this.isValidDefaultBranch()}
|
||||||
|
errorMessage={t("scm-git-plugin.config.defaultBranchValidationError")}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
"gcExpressionHelpText": "Benutze Quartz Cron Ausdrücke (SECOND MINUTE HOUR DAYOFMONTH MONTH DAYOFWEEK), um git GC regelmäßig auszuführen.",
|
"gcExpressionHelpText": "Benutze Quartz Cron Ausdrücke (SECOND MINUTE HOUR DAYOFMONTH MONTH DAYOFWEEK), um git GC regelmäßig auszuführen.",
|
||||||
"nonFastForwardDisallowed": "Deaktiviere \"Non Fast-Forward\"",
|
"nonFastForwardDisallowed": "Deaktiviere \"Non Fast-Forward\"",
|
||||||
"nonFastForwardDisallowedHelpText": "Git Pushes ablehnen, die nicht \"fast-forward\" sind, wie \"--force\".",
|
"nonFastForwardDisallowedHelpText": "Git Pushes ablehnen, die nicht \"fast-forward\" sind, wie \"--force\".",
|
||||||
|
"defaultBranch": "Default Branch",
|
||||||
|
"defaultBranchValidationError": "Dies ist kein valider Branchname",
|
||||||
"disabled": "Deaktiviert",
|
"disabled": "Deaktiviert",
|
||||||
"disabledHelpText": "Aktiviere oder deaktiviere das Git Plugin",
|
"disabledHelpText": "Aktiviere oder deaktiviere das Git Plugin",
|
||||||
"submit": "Speichern"
|
"submit": "Speichern"
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
"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",
|
"nonFastForwardDisallowed": "Disallow Non Fast-Forward",
|
||||||
"nonFastForwardDisallowedHelpText": "Reject git pushes which are non fast-forward such as --force.",
|
"nonFastForwardDisallowedHelpText": "Reject git pushes which are non fast-forward such as --force.",
|
||||||
|
"defaultBranch": "Default Branch",
|
||||||
|
"defaultBranchValidationError": "This is not a valid branch name",
|
||||||
"disabled": "Disabled",
|
"disabled": "Disabled",
|
||||||
"disabledHelpText": "Enable or disable the Git plugin",
|
"disabledHelpText": "Enable or disable the Git plugin",
|
||||||
"submit": "Submit"
|
"submit": "Submit"
|
||||||
|
|||||||
Reference in New Issue
Block a user