'Show merge commits' option in repository settings
This commit is contained in:
		
							parent
							
								
									3a3771db64
								
							
						
					
					
						commit
						808b1dc0c5
					
				@ -78,6 +78,10 @@ public class DefaultCacheCleanupService implements CacheCleanupService {
 | 
			
		||||
                clearCacheByName("assets");
 | 
			
		||||
                clearCacheByName("repositorySettings");
 | 
			
		||||
                break;
 | 
			
		||||
            case "3.4.2":
 | 
			
		||||
                log.info("Clearing cache to upgrade from version 3.4.2 to 3.4.3 ...");
 | 
			
		||||
                clearCacheByName("repositorySettings");
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                //Do nothing, since cache cleanup is optional.
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -32,6 +32,7 @@ public class RepositorySettings implements Serializable {
 | 
			
		||||
    private String privateKeyPassword;
 | 
			
		||||
    private String defaultBranch;
 | 
			
		||||
    private boolean readOnly;
 | 
			
		||||
    private boolean showMergeCommits;
 | 
			
		||||
 | 
			
		||||
    public RepositorySettings() {
 | 
			
		||||
    }
 | 
			
		||||
@ -46,5 +47,6 @@ public class RepositorySettings implements Serializable {
 | 
			
		||||
        this.privateKeyPassword = settings.getPrivateKeyPassword();
 | 
			
		||||
        this.defaultBranch = settings.getDefaultBranch();
 | 
			
		||||
        this.readOnly = settings.isReadOnly();
 | 
			
		||||
        this.showMergeCommits = settings.isShowMergeCommits();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -197,12 +197,7 @@ public class GitRepository {
 | 
			
		||||
        LogCommand command = git.log()
 | 
			
		||||
                .add(branchId);
 | 
			
		||||
 | 
			
		||||
        if (StringUtils.isNotEmpty(pageLink.getTextSearch())) {
 | 
			
		||||
            command.setRevFilter(new NoMergesAndCommitMessageFilter(pageLink.getTextSearch()));
 | 
			
		||||
        } else {
 | 
			
		||||
            command.setRevFilter(RevFilter.NO_MERGES);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        command.setRevFilter(new CommitFilter(pageLink.getTextSearch(), settings.isShowMergeCommits()));
 | 
			
		||||
        if (StringUtils.isNotEmpty(path)) {
 | 
			
		||||
            command.addPath(path);
 | 
			
		||||
        }
 | 
			
		||||
@ -478,17 +473,20 @@ public class GitRepository {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static class NoMergesAndCommitMessageFilter extends RevFilter {
 | 
			
		||||
    private static class CommitFilter extends RevFilter {
 | 
			
		||||
 | 
			
		||||
        private final String textSearch;
 | 
			
		||||
        private final boolean showMergeCommits;
 | 
			
		||||
 | 
			
		||||
        NoMergesAndCommitMessageFilter(String textSearch) {
 | 
			
		||||
        CommitFilter(String textSearch, boolean showMergeCommits) {
 | 
			
		||||
            this.textSearch = textSearch.toLowerCase();
 | 
			
		||||
            this.showMergeCommits = showMergeCommits;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public boolean include(RevWalk walker, RevCommit c) {
 | 
			
		||||
            return c.getParentCount() < 2 && c.getFullMessage().toLowerCase().contains(this.textSearch);
 | 
			
		||||
            return (showMergeCommits || c.getParentCount() < 2) && (StringUtils.isEmpty(textSearch)
 | 
			
		||||
                    || c.getFullMessage().toLowerCase().contains(textSearch));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
@ -501,10 +499,6 @@ public class GitRepository {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public String toString() {
 | 
			
		||||
            return "NO_MERGES_AND_COMMIT_MESSAGE";
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Data
 | 
			
		||||
 | 
			
		||||
@ -44,6 +44,11 @@
 | 
			
		||||
          <mat-checkbox formControlName="readOnly">
 | 
			
		||||
            {{ 'admin.repository-read-only' | translate }}
 | 
			
		||||
          </mat-checkbox>
 | 
			
		||||
          <div>
 | 
			
		||||
            <mat-checkbox formControlName="showMergeCommits">
 | 
			
		||||
              {{ 'admin.show-merge-commits' | translate }}
 | 
			
		||||
            </mat-checkbox>
 | 
			
		||||
          </div>
 | 
			
		||||
          <fieldset [disabled]="isLoading$ | async" class="fields-group">
 | 
			
		||||
            <legend class="group-title" translate>admin.authentication-settings</legend>
 | 
			
		||||
            <mat-form-field fxFlex class="mat-block">
 | 
			
		||||
 | 
			
		||||
@ -75,6 +75,7 @@ export class RepositorySettingsComponent extends PageComponent implements OnInit
 | 
			
		||||
      repositoryUri: [null, [Validators.required]],
 | 
			
		||||
      defaultBranch: ['main', []],
 | 
			
		||||
      readOnly: [false, []],
 | 
			
		||||
      showMergeCommits: [false, []],
 | 
			
		||||
      authMethod: [RepositoryAuthMethod.USERNAME_PASSWORD, [Validators.required]],
 | 
			
		||||
      username: [null, []],
 | 
			
		||||
      password: [null, []],
 | 
			
		||||
 | 
			
		||||
@ -418,6 +418,7 @@ export const repositoryAuthMethodTranslationMap = new Map<RepositoryAuthMethod,
 | 
			
		||||
export interface RepositorySettings {
 | 
			
		||||
  repositoryUri: string;
 | 
			
		||||
  defaultBranch: string;
 | 
			
		||||
  showMergeCommits: boolean;
 | 
			
		||||
  authMethod: RepositoryAuthMethod;
 | 
			
		||||
  username: string;
 | 
			
		||||
  password: string;
 | 
			
		||||
 | 
			
		||||
@ -329,6 +329,7 @@
 | 
			
		||||
        "repository-url-required": "Repository URL is required.",
 | 
			
		||||
        "default-branch": "Default branch name",
 | 
			
		||||
        "repository-read-only": "Read-only",
 | 
			
		||||
        "show-merge-commits": "Show merge commits",
 | 
			
		||||
        "authentication-settings": "Authentication settings",
 | 
			
		||||
        "auth-method": "Authentication method",
 | 
			
		||||
        "auth-method-username-password": "Password / access token",
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user