Snippets

Adaptavist Forget about project/repos...

Created by Jamie Echlin
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.stash.repository.RepositoryService
import com.onresolve.scriptrunner.canned.stash.mirror.AbstractGitMirror

// modify the project keys for whatever repositories you want it to forget about
def stopSyncingProjects = ["ABC", "DEF"]

def repositoryService = ComponentLocator.getComponent(RepositoryService)

def remoteRepos = AbstractGitMirror.getRemoteRepos()
def remotes = remoteRepos.remotes.values()
def remotesToRemove = remotes.findAll {
    def repository = repositoryService.getById(it.repositoryId)
    repository?.project?.key in stopSyncingProjects
}

remotes.removeAll(remotesToRemove)
AbstractGitMirror.saveRemoteRepos(remoteRepos)

"Done"

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.