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 String defaultBranch;
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("squid:S1185") // We want to have this method available in this package
|
||||
protected HalRepresentation add(Links links) {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.repository;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
@@ -33,7 +33,6 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@XmlRootElement(name = "config")
|
||||
@@ -49,6 +48,9 @@ public class GitConfig extends RepositoryConfig {
|
||||
@XmlElement(name = "disallow-non-fast-forward")
|
||||
private boolean nonFastForwardDisallowed;
|
||||
|
||||
@XmlElement(name = "default-branch")
|
||||
private String defaultBranch = "main";
|
||||
|
||||
public String getGcExpression() {
|
||||
return gcExpression;
|
||||
}
|
||||
@@ -65,6 +67,14 @@ public class GitConfig extends RepositoryConfig {
|
||||
this.nonFastForwardDisallowed = nonFastForwardDisallowed;
|
||||
}
|
||||
|
||||
public String getDefaultBranch() {
|
||||
return defaultBranch;
|
||||
}
|
||||
|
||||
public void setDefaultBranch(String defaultBranch) {
|
||||
this.defaultBranch = defaultBranch;
|
||||
}
|
||||
|
||||
@Override
|
||||
@XmlTransient // Only for permission checks, don't serialize to XML
|
||||
public String getId() {
|
||||
|
||||
@@ -24,12 +24,13 @@
|
||||
import React from "react";
|
||||
import { WithTranslation, withTranslation } from "react-i18next";
|
||||
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 = {
|
||||
repositoryDirectory?: string;
|
||||
gcExpression?: string;
|
||||
nonFastForwardDisallowed: boolean;
|
||||
defaultBranch: string;
|
||||
_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() {
|
||||
const { gcExpression, nonFastForwardDisallowed } = this.state;
|
||||
const { gcExpression, nonFastForwardDisallowed, defaultBranch } = this.state;
|
||||
const { readOnly, t } = this.props;
|
||||
|
||||
return (
|
||||
@@ -90,6 +104,15 @@ class GitConfigurationForm extends React.Component<Props, State> {
|
||||
onChange={this.onNonFastForwardDisallowed}
|
||||
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.",
|
||||
"nonFastForwardDisallowed": "Deaktiviere \"Non Fast-Forward\"",
|
||||
"nonFastForwardDisallowedHelpText": "Git Pushes ablehnen, die nicht \"fast-forward\" sind, wie \"--force\".",
|
||||
"defaultBranch": "Default Branch",
|
||||
"defaultBranchValidationError": "Dies ist kein valider Branchname",
|
||||
"disabled": "Deaktiviert",
|
||||
"disabledHelpText": "Aktiviere oder deaktiviere das Git Plugin",
|
||||
"submit": "Speichern"
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
"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.",
|
||||
"defaultBranch": "Default Branch",
|
||||
"defaultBranchValidationError": "This is not a valid branch name",
|
||||
"disabled": "Disabled",
|
||||
"disabledHelpText": "Enable or disable the Git plugin",
|
||||
"submit": "Submit"
|
||||
|
||||
Reference in New Issue
Block a user