mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ICS read-only sources — do not walk outside of dir tree
Update jgit to 5.0.0
This commit is contained in:
@@ -662,7 +662,9 @@ class SchemeManagerImpl<T : Any, MUTABLE_SCHEME : T>(val fileSpec: String,
|
||||
override fun toString(): String = fileSpec
|
||||
}
|
||||
|
||||
internal fun nameIsMissed(bytes: ByteArray) = RuntimeException("Name is missed:\n${bytes.toString(Charsets.UTF_8)}")
|
||||
internal fun nameIsMissed(bytes: ByteArray): RuntimeException {
|
||||
return RuntimeException("Name is missed:\n${bytes.toString(Charsets.UTF_8)}")
|
||||
}
|
||||
|
||||
internal class SchemeDataHolderImpl<out T : Any, in MUTABLE_SCHEME : T>(private val processor: SchemeProcessor<T, MUTABLE_SCHEME>,
|
||||
private val bytes: ByteArray,
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.settingsRepository.git
|
||||
|
||||
import com.intellij.openapi.progress.ProcessCanceledException
|
||||
@@ -35,7 +21,6 @@ import org.eclipse.jgit.transport.RemoteConfig
|
||||
import org.eclipse.jgit.transport.Transport
|
||||
import org.eclipse.jgit.treewalk.FileTreeIterator
|
||||
import org.eclipse.jgit.treewalk.TreeWalk
|
||||
import org.eclipse.jgit.treewalk.filter.TreeFilter
|
||||
import org.jetbrains.settingsRepository.AuthenticationException
|
||||
import org.jetbrains.settingsRepository.IcsCredentialsStore
|
||||
import org.jetbrains.settingsRepository.LOG
|
||||
@@ -205,16 +190,17 @@ fun Repository.processChildren(path: String, filter: ((name: String) -> Boolean)
|
||||
val lastCommitId = resolve(Constants.FETCH_HEAD) ?: return
|
||||
val reader = newObjectReader()
|
||||
reader.use {
|
||||
val treeWalk = TreeWalk.forPath(reader, path, RevWalk(reader).parseCommit(lastCommitId).tree) ?: return
|
||||
if (!treeWalk.isSubtree) {
|
||||
val rootTreeWalk = TreeWalk.forPath(reader, path, RevWalk(reader).parseCommit(lastCommitId).tree) ?: return
|
||||
if (!rootTreeWalk.isSubtree) {
|
||||
// not a directory
|
||||
LOG.warn("File $path is not a directory")
|
||||
return
|
||||
}
|
||||
|
||||
treeWalk.filter = TreeFilter.ALL
|
||||
treeWalk.enterSubtree()
|
||||
|
||||
// https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/ListFilesOfCommitAndTag.java
|
||||
val treeWalk = TreeWalk(this)
|
||||
treeWalk.addTree(rootTreeWalk.getObjectId(0))
|
||||
treeWalk.isRecursive = false
|
||||
while (treeWalk.next()) {
|
||||
val fileMode = treeWalk.getFileMode(0)
|
||||
if (fileMode == FileMode.REGULAR_FILE || fileMode == FileMode.SYMLINK || fileMode == FileMode.EXECUTABLE_FILE) {
|
||||
|
||||
@@ -1,22 +1,9 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.settingsRepository.test
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.testFramework.TemporaryDirectory
|
||||
import com.intellij.util.SmartList
|
||||
import gnu.trove.THashMap
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.jetbrains.settingsRepository.git.cloneBare
|
||||
@@ -40,10 +27,17 @@ internal class BareGitTest {
|
||||
val remoteRepository = tempDirManager.createRepository()
|
||||
val filePath = "keymaps/Mac OS X from RubyMine.xml"
|
||||
remoteRepository.add(filePath, SAMPLE_FILE_CONTENT)
|
||||
remoteRepository.add("keymapsZ.xml", "test")
|
||||
remoteRepository.commit("")
|
||||
|
||||
val repository = cloneBare(remoteRepository.workTree.absolutePath, tempDirManager.newPath())
|
||||
assertThat(FileUtil.loadTextAndClose(repository.read(filePath)!!)).isEqualTo(SAMPLE_FILE_CONTENT)
|
||||
|
||||
val list = SmartList<String>()
|
||||
repository.processChildren("keymaps") { name, _ ->
|
||||
list.add(name)
|
||||
}
|
||||
assertThat(list).containsOnly("Mac OS X from RubyMine.xml")
|
||||
}
|
||||
|
||||
@Test fun processChildren() {
|
||||
|
||||
Reference in New Issue
Block a user