diff --git a/docs/de/user/repo/assets/repository-settings-general-git.png b/docs/de/user/repo/assets/repository-settings-general-git.png new file mode 100644 index 0000000000..eb65995727 Binary files /dev/null and b/docs/de/user/repo/assets/repository-settings-general-git.png differ diff --git a/docs/de/user/repo/settings.md b/docs/de/user/repo/settings.md index 39c2b90569..fe8ebf9b61 100644 --- a/docs/de/user/repo/settings.md +++ b/docs/de/user/repo/settings.md @@ -11,6 +11,9 @@ Unter dem Eintrag "Generell" kann man die Zusatzinformationen zum Repository edi Git Repository handelt, kann ebenfalls der Standard-Branch für dieses Repository gesetzt werden. Der Standard-Branch sorgt dafür, dass beim Arbeiten mit diesem Repository dieser Branch vorrangig geöffnet wird, falls kein expliziter Branch ausgewählt wurde. +Außerdem können Git Pushes auf Repository-Ebene abgelehnt werden, die nicht "fast-forward" sind. + +![Repository-Settings-General-Git](assets/repository-settings-general-git.png) Innerhalb der Gefahrenzone unten auf der Seite gibt es mit entsprechenden Rechten die Möglichkeit das Repository umzubenennen, zu löschen oder als archiviert zu markieren. Wenn in der globalen SCM-Manager Konfiguration die Namespace diff --git a/docs/en/user/repo/assets/repository-settings-general-git.png b/docs/en/user/repo/assets/repository-settings-general-git.png new file mode 100644 index 0000000000..f33aeedbaf Binary files /dev/null and b/docs/en/user/repo/assets/repository-settings-general-git.png differ diff --git a/docs/en/user/repo/assets/repository-settings-general-svn.png b/docs/en/user/repo/assets/repository-settings-general-svn.png deleted file mode 100644 index e6e24a091e..0000000000 Binary files a/docs/en/user/repo/assets/repository-settings-general-svn.png and /dev/null differ diff --git a/docs/en/user/repo/settings.md b/docs/en/user/repo/settings.md index 8a7bdd9162..4a0265326b 100644 --- a/docs/en/user/repo/settings.md +++ b/docs/en/user/repo/settings.md @@ -10,6 +10,9 @@ can be considerably more items. The "General" item allows you to edit the additional information of the repository. Git repositories for example also have the option to change the default branch here. The default branch is the one that is used when working with the repository if no specific branch is selected. +In addition, Git pushes which are non fast-forward can be rejected at the repository level. + +![Repository-Settings-General-Git](assets/repository-settings-general-git.png) In the danger zone at the bottom you may rename the repository, delete it or mark it as archived. If the namespace strategy in the global SCM-Manager config is set to `custom` you may even rename the repository namespace. If a diff --git a/gradle/changelog/repository_fastforward.yaml b/gradle/changelog/repository_fastforward.yaml new file mode 100644 index 0000000000..d48000db9c --- /dev/null +++ b/gradle/changelog/repository_fastforward.yaml @@ -0,0 +1,2 @@ +- type: added + description: Add repository-specific non-fast-forward disallowed option ([#1579](https://github.com/scm-manager/scm-manager/issues/1579)) diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigDto.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigDto.java index 46eb671d5c..d0265ed3bf 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigDto.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigDto.java @@ -40,6 +40,8 @@ public class GitRepositoryConfigDto extends HalRepresentation implements UpdateG private String defaultBranch; + private boolean nonFastForwardDisallowed; + @Override @SuppressWarnings("squid:S1185") // We want to have this method available in this package protected HalRepresentation add(Links links) { diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigResource.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigResource.java index eff864559d..69f8815dda 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigResource.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigResource.java @@ -119,7 +119,7 @@ public class GitRepositoryConfigResource { schema = @Schema(implementation = UpdateGitRepositoryConfigDto.class), examples = @ExampleObject( name = "Overwrites current configuration with this one.", - value = "{\n \"defaultBranch\":\"main\"\n}", + value = "{\n \"defaultBranch\":\"main\"\n \"nonFastForwardDisallowed\":false,\n}", summary = "Simple update configuration" ) ) diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigStoreProvider.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigStoreProvider.java index 38e2559fd1..be96f80859 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigStoreProvider.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/GitRepositoryConfigStoreProvider.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + package sonia.scm.api.v2.resources; import sonia.scm.event.ScmEventBus; @@ -42,7 +42,22 @@ public class GitRepositoryConfigStoreProvider { } public ConfigurationStore get(Repository repository) { - return new StoreWrapper(configurationStoreFactory.withType(GitRepositoryConfig.class).withName("gitConfig").forRepository(repository).build(), repository); + return new StoreWrapper(createStore(repository.getId()), repository); + } + + public GitRepositoryConfig getGitRepositoryConfig(String repositoryId) { + return getFronStore(createStore(repositoryId)); + } + + private static GitRepositoryConfig getFronStore(ConfigurationStore store) { + return store.getOptional().orElse(new GitRepositoryConfig()); + } + + private ConfigurationStore createStore(String id) { + return configurationStoreFactory + .withType(GitRepositoryConfig.class) + .withName("gitConfig") + .forRepository(id).build(); } private static class StoreWrapper implements ConfigurationStore { @@ -57,11 +72,7 @@ public class GitRepositoryConfigStoreProvider { @Override public GitRepositoryConfig get() { - GitRepositoryConfig config = delegate.get(); - if (config == null) { - return new GitRepositoryConfig(); - } - return config; + return getFronStore(delegate); } @Override diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateGitRepositoryConfigDto.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateGitRepositoryConfigDto.java index 0da843e1af..5af2dd869f 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateGitRepositoryConfigDto.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/api/v2/resources/UpdateGitRepositoryConfigDto.java @@ -26,4 +26,5 @@ package sonia.scm.api.v2.resources; interface UpdateGitRepositoryConfigDto { String getDefaultBranch(); + boolean isNonFastForwardDisallowed(); } diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/protocolcommand/git/BaseReceivePackFactory.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/protocolcommand/git/BaseReceivePackFactory.java index 18840670c6..fd6ac85464 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/protocolcommand/git/BaseReceivePackFactory.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/protocolcommand/git/BaseReceivePackFactory.java @@ -29,7 +29,9 @@ import org.eclipse.jgit.transport.ReceivePack; import org.eclipse.jgit.transport.resolver.ReceivePackFactory; import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException; import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; +import sonia.scm.api.v2.resources.GitRepositoryConfigStoreProvider; import sonia.scm.repository.GitChangesetConverterFactory; +import sonia.scm.repository.GitRepositoryConfig; import sonia.scm.repository.GitRepositoryHandler; import sonia.scm.web.CollectingPackParserListener; import sonia.scm.web.GitHookEventFacade; @@ -39,16 +41,21 @@ public abstract class BaseReceivePackFactory implements ReceivePackFactory private final GitRepositoryHandler handler; private final GitReceiveHook hook; + private final GitRepositoryConfigStoreProvider storeProvider; - protected BaseReceivePackFactory(GitChangesetConverterFactory converterFactory, GitRepositoryHandler handler, GitHookEventFacade hookEventFacade) { + protected BaseReceivePackFactory(GitChangesetConverterFactory converterFactory, + GitRepositoryHandler handler, + GitHookEventFacade hookEventFacade, + GitRepositoryConfigStoreProvider storeProvider) { this.handler = handler; + this.storeProvider = storeProvider; this.hook = new GitReceiveHook(converterFactory, hookEventFacade, handler); } @Override public final ReceivePack create(T connection, Repository repository) throws ServiceNotAuthorizedException, ServiceNotEnabledException { ReceivePack receivePack = createBasicReceivePack(connection, repository); - receivePack.setAllowNonFastForwards(isNonFastForwardAllowed()); + receivePack.setAllowNonFastForwards(isNonFastForwardAllowed(repository)); receivePack.setPreReceiveHook(hook); receivePack.setPostReceiveHook(hook); @@ -61,7 +68,9 @@ public abstract class BaseReceivePackFactory implements ReceivePackFactory protected abstract ReceivePack createBasicReceivePack(T request, Repository repository) throws ServiceNotEnabledException, ServiceNotAuthorizedException; - private boolean isNonFastForwardAllowed() { - return ! handler.getConfig().isNonFastForwardDisallowed(); + private boolean isNonFastForwardAllowed(Repository repository) { + String repositoryId = handler.getRepositoryId(repository.getConfig()); + GitRepositoryConfig gitRepositoryConfig = storeProvider.getGitRepositoryConfig(repositoryId); + return !(handler.getConfig().isNonFastForwardDisallowed() || gitRepositoryConfig.isNonFastForwardDisallowed()); } } diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/protocolcommand/git/ScmReceivePackFactory.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/protocolcommand/git/ScmReceivePackFactory.java index 8fe5e5ce3b..357affcc97 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/protocolcommand/git/ScmReceivePackFactory.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/protocolcommand/git/ScmReceivePackFactory.java @@ -27,6 +27,7 @@ package sonia.scm.protocolcommand.git; import com.google.inject.Inject; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.transport.ReceivePack; +import sonia.scm.api.v2.resources.GitRepositoryConfigStoreProvider; import sonia.scm.protocolcommand.RepositoryContext; import sonia.scm.repository.GitChangesetConverterFactory; import sonia.scm.repository.GitRepositoryHandler; @@ -35,8 +36,11 @@ import sonia.scm.web.GitHookEventFacade; public class ScmReceivePackFactory extends BaseReceivePackFactory { @Inject - public ScmReceivePackFactory(GitChangesetConverterFactory converterFactory, GitRepositoryHandler handler, GitHookEventFacade hookEventFacade) { - super(converterFactory, handler, hookEventFacade); + public ScmReceivePackFactory(GitChangesetConverterFactory converterFactory, + GitRepositoryHandler handler, + GitHookEventFacade hookEventFacade, + GitRepositoryConfigStoreProvider gitRepositoryConfigStoreProvider) { + super(converterFactory, handler, hookEventFacade, gitRepositoryConfigStoreProvider); } @Override diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitRepositoryConfig.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitRepositoryConfig.java index c59c51913d..e4b2b7e2f9 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitRepositoryConfig.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/repository/GitRepositoryConfig.java @@ -40,6 +40,7 @@ public class GitRepositoryConfig { } private String defaultBranch; + private boolean nonFastForwardDisallowed; public String getDefaultBranch() { return defaultBranch; @@ -48,4 +49,10 @@ public class GitRepositoryConfig { public void setDefaultBranch(String defaultBranch) { this.defaultBranch = defaultBranch; } + + public boolean isNonFastForwardDisallowed() { return nonFastForwardDisallowed; } + + public void setNonFastForwardDisallowed(boolean nonFastForwardDisallowed) { + this.nonFastForwardDisallowed = nonFastForwardDisallowed; + } } diff --git a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitReceivePackFactory.java b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitReceivePackFactory.java index 49cfed592d..9db075bfd5 100644 --- a/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitReceivePackFactory.java +++ b/scm-plugins/scm-git-plugin/src/main/java/sonia/scm/web/GitReceivePackFactory.java @@ -33,6 +33,7 @@ import org.eclipse.jgit.transport.ReceivePack; import org.eclipse.jgit.transport.resolver.ReceivePackFactory; import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException; import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; +import sonia.scm.api.v2.resources.GitRepositoryConfigStoreProvider; import sonia.scm.protocolcommand.git.BaseReceivePackFactory; import sonia.scm.repository.GitChangesetConverterFactory; import sonia.scm.repository.GitRepositoryHandler; @@ -53,8 +54,11 @@ public class GitReceivePackFactory extends BaseReceivePackFactory wrapped; @Inject - public GitReceivePackFactory(GitChangesetConverterFactory converterFactory, GitRepositoryHandler handler, GitHookEventFacade hookEventFacade) { - super(converterFactory, handler, hookEventFacade); + public GitReceivePackFactory(GitChangesetConverterFactory converterFactory, + GitRepositoryHandler handler, + GitHookEventFacade hookEventFacade, + GitRepositoryConfigStoreProvider gitRepositoryConfigStoreProvider) { + super(converterFactory, handler, hookEventFacade, gitRepositoryConfigStoreProvider); this.wrapped = new DefaultReceivePackFactory(); } diff --git a/scm-plugins/scm-git-plugin/src/main/js/RepositoryConfig.tsx b/scm-plugins/scm-git-plugin/src/main/js/RepositoryConfig.tsx index 500692941b..045b0836c4 100644 --- a/scm-plugins/scm-git-plugin/src/main/js/RepositoryConfig.tsx +++ b/scm-plugins/scm-git-plugin/src/main/js/RepositoryConfig.tsx @@ -27,6 +27,7 @@ import { Branch, Repository, Link } from "@scm-manager/ui-types"; import { apiClient, BranchSelector, + Checkbox, ErrorPage, Loading, Subtitle, @@ -45,8 +46,10 @@ type State = { error?: Error; branches: Branch[]; selectedBranchName: string; - defaultBranchChanged: boolean; + nonFastForwardDisallowed: boolean; + changesSubmitted: boolean; disabled: boolean; + changed: boolean; }; const GIT_CONFIG_CONTENT_TYPE = "application/vnd.scmm-gitConfig+json"; @@ -61,15 +64,16 @@ class RepositoryConfig extends React.Component { submitPending: false, branches: [], selectedBranchName: "", - defaultBranchChanged: false, - disabled: true + nonFastForwardDisallowed: false, + changesSubmitted: false, + disabled: true, + changed: false }; } componentDidMount() { const { repository } = this.props; this.setState({ - ...this.state, loadingBranches: true }); const branchesLink = repository._links.branches as Link; @@ -79,21 +83,18 @@ class RepositoryConfig extends React.Component { .then(payload => payload._embedded.branches) .then(branches => this.setState({ - ...this.state, branches, loadingBranches: false }) ) .catch(error => this.setState({ - ...this.state, error }) ); const configurationLink = repository._links.configuration as Link; this.setState({ - ...this.state, loadingDefaultBranch: true }); apiClient @@ -101,15 +102,15 @@ class RepositoryConfig extends React.Component { .then(response => response.json()) .then(payload => this.setState({ - ...this.state, selectedBranchName: payload.defaultBranch, + nonFastForwardDisallowed: payload.nonFastForwardDisallowed, disabled: !payload._links.update, - loadingDefaultBranch: false + loadingDefaultBranch: false, + changed: false }) ) .catch(error => this.setState({ - ...this.state, error }) ); @@ -118,28 +119,36 @@ class RepositoryConfig extends React.Component { branchSelected = (branch?: Branch) => { if (!branch) { this.setState({ - ...this.state, selectedBranchName: "", - defaultBranchChanged: false + changesSubmitted: false, + changed: true }); } else { this.setState({ - ...this.state, selectedBranchName: branch.name, - defaultBranchChanged: false + changesSubmitted: false, + changed: true }); } }; + onNonFastForwardDisallowed = (value: boolean) => { + this.setState({ + nonFastForwardDisallowed: value, + changed: true + }); + }; + submit = (event: FormEvent) => { event.preventDefault(); const { repository } = this.props; + const { selectedBranchName, nonFastForwardDisallowed } = this.state; const newConfig = { - defaultBranch: this.state.selectedBranchName + defaultBranch: selectedBranchName, + nonFastForwardDisallowed }; this.setState({ - ...this.state, submitPending: true }); const configurationLink = repository._links.configuration as Link; @@ -147,14 +156,13 @@ class RepositoryConfig extends React.Component { .put(configurationLink.href, newConfig, GIT_CONFIG_CONTENT_TYPE) .then(() => this.setState({ - ...this.state, submitPending: false, - defaultBranchChanged: true + changesSubmitted: true, + changed: false }) ) .catch(error => this.setState({ - ...this.state, error }) ); @@ -162,13 +170,13 @@ class RepositoryConfig extends React.Component { render() { const { t } = this.props; - const { loadingBranches, loadingDefaultBranch, submitPending, error, disabled } = this.state; + const { loadingBranches, loadingDefaultBranch, submitPending, error, disabled, changed } = this.state; if (error) { return ( ); @@ -177,27 +185,32 @@ class RepositoryConfig extends React.Component { const submitButton = disabled ? null : ( + } /> ); if (!(loadingBranches || loadingDefaultBranch)) { + const { branches, selectedBranchName, nonFastForwardDisallowed } = this.state; return ( <>
- + {this.renderBranchChangedNotification()}
+ {submitButton} @@ -210,19 +223,19 @@ class RepositoryConfig extends React.Component { } renderBranchChangedNotification = () => { - if (this.state.defaultBranchChanged) { + if (this.state.changesSubmitted) { return (
); } diff --git a/scm-plugins/scm-git-plugin/src/main/resources/locales/de/plugins.json b/scm-plugins/scm-git-plugin/src/main/resources/locales/de/plugins.json index ad452fd559..05aa65485b 100644 --- a/scm-plugins/scm-git-plugin/src/main/resources/locales/de/plugins.json +++ b/scm-plugins/scm-git-plugin/src/main/resources/locales/de/plugins.json @@ -31,16 +31,17 @@ "disabledHelpText": "Aktiviere oder deaktiviere das Git Plugin", "submit": "Speichern" }, - "repo-config": { - "link": "Konfiguration", + "repoConfig": { "title": "Git Einstellungen", - "default-branch": "Standard Branch", + "defaultBranch": "Default Branch", + "nonFastForwardDisallowed": "Deaktiviere \"Non Fast-Forward\"", + "nonFastForwardDisallowedHelpText": "Git Pushes ablehnen, die nicht \"fast-forward\" sind, wie \"--force\".", "submit": "Speichern", "error": { "title": "Fehler", "subtitle": "Ein Fehler ist aufgetreten." }, - "success": "Der standard Branch wurde geändert!" + "success": "Einstellungen wurden erfolgreich geändert!" } }, "permissions": { diff --git a/scm-plugins/scm-git-plugin/src/main/resources/locales/en/plugins.json b/scm-plugins/scm-git-plugin/src/main/resources/locales/en/plugins.json index 432f0e6608..c28cb82e0c 100644 --- a/scm-plugins/scm-git-plugin/src/main/resources/locales/en/plugins.json +++ b/scm-plugins/scm-git-plugin/src/main/resources/locales/en/plugins.json @@ -31,16 +31,17 @@ "disabledHelpText": "Enable or disable the Git plugin", "submit": "Submit" }, - "repo-config": { - "link": "Configuration", + "repoConfig": { "title": "Git Settings", - "default-branch": "Default Branch", + "defaultBranch": "Default Branch", + "nonFastForwardDisallowed": "Disallow Non Fast-Forward", + "nonFastForwardDisallowedHelpText": "Reject git pushes which are non fast-forward such as --force.", "submit": "Submit", "error": { "title": "Error", "subtitle": "Something went wrong" }, - "success": "Default branch changed!" + "success": "Configuration changed successfully!" } }, "permissions" : { diff --git a/scm-plugins/scm-git-plugin/src/test/java/sonia/scm/protocolcommand/git/BaseReceivePackFactoryTest.java b/scm-plugins/scm-git-plugin/src/test/java/sonia/scm/protocolcommand/git/BaseReceivePackFactoryTest.java index cc178c2ef8..e59c5b5896 100644 --- a/scm-plugins/scm-git-plugin/src/test/java/sonia/scm/protocolcommand/git/BaseReceivePackFactoryTest.java +++ b/scm-plugins/scm-git-plugin/src/test/java/sonia/scm/protocolcommand/git/BaseReceivePackFactoryTest.java @@ -38,7 +38,9 @@ import org.junit.rules.TemporaryFolder; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import sonia.scm.api.v2.resources.GitRepositoryConfigStoreProvider; import sonia.scm.repository.GitConfig; +import sonia.scm.repository.GitRepositoryConfig; import sonia.scm.repository.GitRepositoryHandler; import sonia.scm.repository.GitTestHelper; import sonia.scm.web.CollectingPackParserListener; @@ -59,17 +61,22 @@ public class BaseReceivePackFactoryTest { @Mock private GitRepositoryHandler handler; - private GitConfig config; + private GitConfig gitConfig; @Mock private ReceivePackFactory wrappedReceivePackFactory; + @Mock + private GitRepositoryConfigStoreProvider gitRepositoryConfigStoreProvider; + private BaseReceivePackFactory factory; private Object request = new Object(); private Repository repository; + private GitRepositoryConfig gitRepositoryConfig = new GitRepositoryConfig(); + @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); @@ -77,13 +84,16 @@ public class BaseReceivePackFactoryTest { public void setUpObjectUnderTest() throws Exception { this.repository = createRepositoryForTesting(); - config = new GitConfig(); - when(handler.getConfig()).thenReturn(config); + gitConfig = new GitConfig(); + when(handler.getConfig()).thenReturn(gitConfig); + when(handler.getRepositoryId(repository.getConfig())).thenReturn("heart-of-gold"); ReceivePack receivePack = new ReceivePack(repository); when(wrappedReceivePackFactory.create(request, repository)).thenReturn(receivePack); - factory = new BaseReceivePackFactory(GitTestHelper.createConverterFactory(), handler, null) { + when(gitRepositoryConfigStoreProvider.getGitRepositoryConfig("heart-of-gold")).thenReturn(gitRepositoryConfig); + + factory = new BaseReceivePackFactory(GitTestHelper.createConverterFactory(), handler, null, gitRepositoryConfigStoreProvider) { @Override protected ReceivePack createBasicReceivePack(Object request, Repository repository) throws ServiceNotEnabledException, ServiceNotAuthorizedException { return wrappedReceivePackFactory.create(request, repository); @@ -108,7 +118,14 @@ public class BaseReceivePackFactoryTest { @Test public void testCreateWithDisabledNonFastForward() throws Exception { - config.setNonFastForwardDisallowed(true); + gitConfig.setNonFastForwardDisallowed(true); + ReceivePack receivePack = factory.create(request, repository); + assertFalse(receivePack.isAllowNonFastForwards()); + } + + @Test + public void testCreateWithLocalDisabledNonFastForward() throws Exception { + gitRepositoryConfig.setNonFastForwardDisallowed(true); ReceivePack receivePack = factory.create(request, repository); assertFalse(receivePack.isAllowNonFastForwards()); }