Skip to content

The Unified and Autonomous Development Platform

fix: Git fetch fails after upgrading Docker image from 13.1.0 to 13.1.4 due to BouncyCastle jar conflicts (OD-2629)

Robin Shen014c6dd39e78
diff --git a/CLAUDE.md b/CLAUDE.md
deleted file mode 100644
index 37f77f7efb..0000000000
--- a/CLAUDE.md
+++ /dev/null
@@ -1,175 +0,0 @@
-# CLAUDE.md
-
-This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
-
-## Build Commands
-
-OneDev uses Maven as its build system with a multi-module structure.
-
-### Essential Commands
-- **Build the project**: `mvn clean compile`
-- **Run tests**: `mvn test`
-- **Package the application**: `mvn clean package`
-- **Build without tests**: `mvn clean package -DskipTests`
-- **Build specific module**: `mvn clean package -pl server-core`
-- **Install to local repository**: `mvn clean install`
-
-### Profiles
-- **Community Edition**: `mvn clean package -Pce` (excludes enterprise features)
-- **Default/Enterprise**: `mvn clean package` (includes all features)
-
-### Testing
-- **Run all tests**: `mvn test`
-- **Run specific test class**: `mvn test -Dtest=ClassName`
-- **Run tests for specific module**: `mvn test -pl server-core`
-
-## Architecture Overview
-
-OneDev is a comprehensive DevOps platform built with a sophisticated multi-module Maven architecture:
-
-### Core Technology Stack
-- **Web Framework**: Apache Wicket 7.18.0 (component-based UI)
-- **REST API**: Jersey 2.38 (JAX-RS implementation)
-- **Database/ORM**: Hibernate 5.4.24.Final with HikariCP connection pooling
-- **Web Server**: Embedded Jetty 9.4.57
-- **Dependency Injection**: Google Guice with custom plugin loading
-- **Security**: Apache Shiro for authentication/authorization
-- **Search**: Apache Lucene 8.7.0
-- **Git**: JGit 5.13.3 for Git operations
-- **Clustering**: Hazelcast 5.3.5 for distributed coordination
-
-### Module Structure
-- **server-core**: Core application logic, entities, and services
-- **server-ee**: Enterprise edition features
-- **server-plugin**: Plugin framework and all plugin implementations
-- **server-product**: Final packaging and deployment artifacts
-
-### Key Subsystems
-
-#### 1. Application Bootstrap
-- Main entry point: `server-core/src/main/java/io/onedev/server/OneDev.java`
-- Module configuration: `server-core/src/main/java/io/onedev/server/CoreModule.java`
-- Handles server lifecycle, clustering, and graceful shutdown
-
-#### 2. Entity Management
-Key domain entities and managers in `server-core/src/main/java/io/onedev/server/model/`:
-- Project, User, Group, Role management
-- Issue tracking with customizable workflows
-- Pull request lifecycle and code review
-- Build and CI/CD pipeline management
-- Package registry operations
-
-#### 3. Git Integration
-- Full Git repository management via JGit
-- Git hooks for policy enforcement in `server-core/src/main/java/io/onedev/server/git/`
-- Code browsing, diff visualization, and blame tracking
-- SSH server for Git operations
-
-#### 4. Web Layer (Wicket)
-- Component-based UI in `server-core/src/main/java/io/onedev/server/web/`
-- AJAX-heavy interface with WebSocket support
-- Project browsing, issue boards, pull request review interface
-
-#### 5. REST API (Jersey)
-- RESTful services in `server-core/src/main/java/io/onedev/server/rest/`
-- Project, User, Build, Issue resources
-- WebHook endpoints and package registry APIs
-
-#### 6. CI/CD System
-- YAML-based build specifications
-- Multi-executor support (Kubernetes, Docker, Shell)
-- Real-time log streaming and artifact management
-
-#### 7. Plugin Architecture
-- Extensible plugin system in `server-plugin/`
-- Categories: build specs, executors, authenticators, importers, notifications, package registries, report processors
-- Plugin contributions via Guice modules
-
-## Development Patterns
-
-### Code Organization
-- **Package-by-feature**: Organized around business capabilities
-- **Dependency Injection**: Guice-based DI throughout the application
-- **Interface-based design**: For testability and modularity
-- **Custom annotations**: Extensive use for validation and metadata
-
-### Design Patterns Used
-- Repository Pattern for data access
-- Observer Pattern for event handling
-- Command Pattern for Git operations
-- Strategy Pattern for pluggable components
-- Template Method for build processing
-
-### Testing Strategy
-- Unit tests in `src/test/java` directories
-- Git operation tests with test repositories
-- Component and integration tests
-- Utility method tests
-- Focus on testing business logic and Git operations
-
-## Common Development Tasks
-
-### Working with Entities
-- Entities are in `server-core/src/main/java/io/onedev/server/model/`
-- Use corresponding managers for database operations
-- Follow JPA/Hibernate patterns for persistence
-
-### Adding REST Endpoints
-- Create resources in `server-core/src/main/java/io/onedev/server/rest/resource/`
-- Follow Jersey/JAX-RS patterns
-- Use existing security annotations for authentication
-
-### Creating Plugins
-- Extend `AbstractPlugin` class
-- Implement appropriate interfaces for the plugin category
-- Add Guice module configuration
-- Place in appropriate `server-plugin/server-plugin-*` module
-
-### Working with Git
-- Use JGit APIs through OneDev's Git service layer
-- Follow patterns in `server-core/src/main/java/io/onedev/server/git/`
-- Handle Git operations asynchronously when possible
-
-### Adding Web Components
-- Create Wicket components in `server-core/src/main/java/io/onedev/server/web/`
-- Follow existing component patterns and CSS frameworks
-- Use AJAX for dynamic behavior
-
-## Configuration and Deployment
-
-### Key Configuration Files
-- `server-product/system/conf/server.properties`: HTTP/SSH ports, clustering
-- `server-product/system/conf/hibernate.properties`: Database configuration
-- `server-product/system/conf/logback.xml`: Logging configuration
-
-### Deployment Options
-- Standalone JAR with embedded Jetty
-- Docker containers (see `server-product/docker/`)
-- Kubernetes via Helm charts (see `server-product/helm/`)
-
-### Database Support
-- PostgreSQL (recommended for production)
-- MySQL/MariaDB
-- HSQLDB (development/testing)
-
-## Performance Considerations
-
-### Caching
-- Hibernate second-level cache with Hazelcast
-- Build artifact caching
-- Git object caching
-- Web resource bundling
-
-### Clustering
-- Hazelcast-based clustering for high availability
-- Distributed session management
-- Leader election for coordinated operations
-
-## Important Notes
-
-- OneDev uses a custom plugin loading framework
-- Git operations are central to the application architecture
-- The system supports both community (CE) and enterprise (EE) editions
-- Extensive use of Guice for dependency injection and plugin management
-- Focus on performance and resource efficiency
-- Battle-tested in production environments for 5+ years
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index f31572b954..d8ec60709a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
<version>1.3.0</version>
</parent>
<artifactId>server</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
<packaging>pom</packaging>
<build>
<finalName>${project.groupId}.${project.artifactId}-${project.version}</finalName>
@@ -372,11 +372,26 @@
<artifactId>snakeyaml</artifactId>
<version>2.2</version>
</dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcpg-jdk18on</artifactId>
+ <version>${bouncycastle.version}</version>
+ </dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<version>${bouncycastle.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcpkix-jdk18on</artifactId>
+ <version>${bouncycastle.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcutil-jdk18on</artifactId>
+ <version>${bouncycastle.version}</version>
+ </dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bctls-jdk18on</artifactId>
@@ -661,8 +676,8 @@
</repository>
</repositories>
<properties>
- <commons.version>3.1.1</commons.version>
- <agent.version>2.3.3</agent.version>
+ <commons.version>3.1.4</commons.version>
+ <agent.version>2.3.6</agent.version>
<slf4j.version>2.0.9</slf4j.version>
<logback.version>1.4.14</logback.version>
<antlr.version>4.7.2</antlr.version>
@@ -672,7 +687,7 @@
<hibernate.version>5.4.24.Final</hibernate.version>
<lucene.version>8.7.0</lucene.version>
<shiro.version>1.13.0</shiro.version>
- <jgit.version>5.13.3.202401111512-r</jgit.version>
+ <jgit.version>6.10.1.202505221210-r</jgit.version>
<flexmark.version>0.64.8</flexmark.version>
<groovy.version>3.0.25</groovy.version>
<servlet.version>3.1.0</servlet.version>
diff --git a/server-core/pom.xml b/server-core/pom.xml
index 35d16822b8..4fc67735a9 100644
--- a/server-core/pom.xml
+++ b/server-core/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<build>
<plugins>
@@ -68,10 +68,22 @@
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcpg-jdk18on</artifactId>
+ </dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcpkix-jdk18on</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcutil-jdk18on</artifactId>
+ </dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bctls-jdk18on</artifactId>
@@ -85,9 +97,13 @@
<artifactId>quartz</artifactId>
<exclusions>
<exclusion>
- <groupId>c3p0</groupId>
+ <groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>com.mchange</groupId>
+ <artifactId>mchange-commons-java</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
@@ -209,6 +225,28 @@
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit.gpg.bc</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcpg-jdk18on</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcprov-jdk18on</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcpkix-jdk18on</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcutil-jdk18on</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bctls-jdk18on</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jgit</groupId>
diff --git a/server-core/src/main/java/io/onedev/server/ai/HighlightedTextTool.java b/server-core/src/main/java/io/onedev/server/ai/HighlightedTextTool.java
new file mode 100644
index 0000000000..c43b5364a1
--- /dev/null
+++ b/server-core/src/main/java/io/onedev/server/ai/HighlightedTextTool.java
@@ -0,0 +1,65 @@
+package io.onedev.server.ai;
+
+import java.util.List;
+import java.util.Map;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Joiner;
+
+import dev.langchain4j.agent.tool.ToolSpecification;
+import io.onedev.commons.utils.PlanarRange;
+import io.onedev.server.OneDev;
+import io.onedev.server.service.support.ChatTool;
+
+public class HighlightedTextTool implements ChatTool {
+
+ private static final String HIGHLIGHT_BEGIN = "[HIGHLIGHT_BEGIN]";
+
+ private static final String HIGHLIGHT_END = "[HIGHLIGHT_END]";
+
+ private static final String OMITTED_LINES = "...OMITTED LINES...";
+
+ private static final int CONTEXT_SIZE = 100;
+
+ private final String fileName;
+
+ private final List<String> fileContent;
+
+ private final PlanarRange highlightRange;
+
+ public HighlightedTextTool(String fileName, List<String> fileContent, PlanarRange highlightRange) {
+ this.fileName = fileName;
+ this.fileContent = fileContent;
+ this.highlightRange = highlightRange;
+ }
+
+ @Override
+ public ToolSpecification getSpecification() {
+ return ToolSpecification.builder()
+ .name("getHighlightedTextInformation")
+ .description("""
+ Get information of highlighted text in json format, including highlighted text itself,
+ name of the file containing highlighted text, and context of highlighted text
+ """)
+ .build();
+ }
+
+ @Override
+ public String execute(JsonNode arguments) {
+ var map = Map.of(
+ "highlightedText", Joiner.on('\n').join(highlightRange.getContent(fileContent)),
+ "nameOfFileContainingHighlightedText", fileName,
+ "contextOfHighlightedText", Joiner.on('\n').join(highlightRange.getContext(fileContent, HIGHLIGHT_BEGIN, HIGHLIGHT_END, OMITTED_LINES, CONTEXT_SIZE, CONTEXT_SIZE, CONTEXT_SIZE)),
+ "note", String.format("Highlighted text is between %s and %s in the context", HIGHLIGHT_BEGIN, HIGHLIGHT_END)
+ );
+
+ try {
+ return OneDev.getInstance(ObjectMapper.class).writeValueAsString(map);
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/server-core/src/main/java/io/onedev/server/git/GitUtils.java b/server-core/src/main/java/io/onedev/server/git/GitUtils.java
index 85732892df..569fd10941 100644
--- a/server-core/src/main/java/io/onedev/server/git/GitUtils.java
+++ b/server-core/src/main/java/io/onedev/server/git/GitUtils.java
@@ -18,8 +18,6 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
-import org.jspecify.annotations.Nullable;
-
import org.bouncycastle.bcpg.ArmoredOutputStream;
import org.bouncycastle.bcpg.BCPGOutputStream;
import org.bouncycastle.bcpg.HashAlgorithmTags;
@@ -66,6 +64,7 @@ import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.jgit.treewalk.filter.TreeFilter;
import org.eclipse.jgit.util.SystemReader;
import org.eclipse.jgit.util.io.NullOutputStream;
+import org.jspecify.annotations.Nullable;
import com.google.common.base.Joiner;
import com.google.common.base.Objects;
@@ -696,8 +695,8 @@ public class GitUtils {
PGPPublicKey publicKey = signingKey.getPublicKey();
PGPSignatureGenerator signatureGenerator = new PGPSignatureGenerator(
- new JcaPGPContentSignerBuilder(publicKey.getAlgorithm(), HashAlgorithmTags.SHA256)
- .setProvider(BouncyCastleProvider.PROVIDER_NAME));
+ new JcaPGPContentSignerBuilder(publicKey.getAlgorithm(), HashAlgorithmTags.SHA256).setProvider(BouncyCastleProvider.PROVIDER_NAME),
+ signingKey.getPublicKey());
try {
signatureGenerator.init(PGPSignature.BINARY_DOCUMENT, privateKey);
PGPSignatureSubpacketGenerator subpackets = new PGPSignatureSubpacketGenerator();
diff --git a/server-core/src/main/java/io/onedev/server/git/signatureverification/DefaultSignatureVerificationService.java b/server-core/src/main/java/io/onedev/server/git/signatureverification/DefaultSignatureVerificationService.java
index 5238f0ada6..e4d1b5643e 100644
--- a/server-core/src/main/java/io/onedev/server/git/signatureverification/DefaultSignatureVerificationService.java
+++ b/server-core/src/main/java/io/onedev/server/git/signatureverification/DefaultSignatureVerificationService.java
@@ -37,7 +37,7 @@ public class DefaultSignatureVerificationService implements SignatureVerificatio
int start = RawParseUtils.headerStart(header, rawCommit, 0);
if (start < 0)
return null;
- int end = RawParseUtils.headerEnd(rawCommit, start);
+ int end = RawParseUtils.nextLfSkippingSplitLines(rawCommit, start);
byte[] signatureData = Arrays.copyOfRange(rawCommit, start, end);
// start is at the beginning of the header's content
diff --git a/server-core/src/main/java/io/onedev/server/util/GpgUtils.java b/server-core/src/main/java/io/onedev/server/util/GpgUtils.java
index e80dba2c05..ba26ba7bad 100644
--- a/server-core/src/main/java/io/onedev/server/util/GpgUtils.java
+++ b/server-core/src/main/java/io/onedev/server/util/GpgUtils.java
@@ -12,6 +12,7 @@ import java.util.Iterator;
import java.util.List;
import org.bouncycastle.bcpg.HashAlgorithmTags;
+import org.bouncycastle.bcpg.PublicKeyPacket;
import org.bouncycastle.bcpg.SymmetricKeyAlgorithmTags;
import org.bouncycastle.bcpg.sig.Features;
import org.bouncycastle.bcpg.sig.KeyFlags;
@@ -93,9 +94,9 @@ public class GpgUtils {
// takes parameters that allow it to generate the self
// signature.
PGPKeyRingGenerator keyRingGen;
- PGPKeyPair rsakp_sign = new BcPGPKeyPair(PGPPublicKey.RSA_SIGN, kpg.generateKeyPair(), new Date());
+ PGPKeyPair rsakp_sign = new BcPGPKeyPair(PublicKeyPacket.VERSION_4, PGPPublicKey.RSA_GENERAL, kpg.generateKeyPair(), new Date());
// Then an encryption subkey.
- PGPKeyPair rsakp_enc = new BcPGPKeyPair(PGPPublicKey.RSA_ENCRYPT, kpg.generateKeyPair(), new Date());
+ PGPKeyPair rsakp_enc = new BcPGPKeyPair(PublicKeyPacket.VERSION_4, PGPPublicKey.RSA_GENERAL, kpg.generateKeyPair(), new Date());
// Add a self-signature on the id
PGPSignatureSubpacketGenerator signhashgen = new PGPSignatureSubpacketGenerator();
diff --git a/server-core/src/main/java/io/onedev/server/web/WebSession.java b/server-core/src/main/java/io/onedev/server/web/WebSession.java
index 3512a26f64..fb921fa1f4 100644
--- a/server-core/src/main/java/io/onedev/server/web/WebSession.java
+++ b/server-core/src/main/java/io/onedev/server/web/WebSession.java
@@ -1,17 +1,16 @@
package io.onedev.server.web;
-import java.io.Serializable;
import java.time.ZoneId;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import javax.servlet.http.HttpSession;
import org.apache.shiro.SecurityUtils;
import org.apache.wicket.protocol.http.WicketServlet;
import org.apache.wicket.request.Request;
+import org.apache.wicket.util.collections.ConcurrentHashSet;
import org.jspecify.annotations.Nullable;
import io.onedev.server.OneDev;
@@ -22,27 +21,27 @@ public class WebSession extends org.apache.wicket.protocol.http.WebSession {
private static final long serialVersionUID = 1L;
- private static final String ATTR_ISSUE_CURSOR = "issueCursor";
-
- private static final String ATTR_BUILD_CURSOR = "buildCursor";
-
- private static final String ATTR_PACK_CURSOR = "packCursor";
-
- private static final String ATTR_PULL_REQUEST_CURSOR = "pullRequestCursor";
-
- private static final String ATTR_ZONE_ID = "zoneId";
+ private volatile Cursor issueCursor;
- private static final String ATTR_REDIRECT_URLS_AFTER_DELETE = "redirectUrlsAfterDelete";
+ private volatile Cursor buildCursor;
+
+ private volatile Cursor packCursor;
+
+ private volatile Cursor pullRequestCursor;
- private static final String ATTR_EXPANDED_PROJECT_IDS = "expandedProjectIds";
+ private volatile ZoneId zoneId;
+
+ private Map<Class<?>, String> redirectUrlsAfterDelete = new ConcurrentHashMap<>();
+
+ private Set<Long> expandedProjectIds = new ConcurrentHashSet<>();
- private static final String ATTR_CHAT_VISIBLE = "chatVisible";
+ private volatile boolean chatVisible;
+
+ private volatile Long activeChatId;
- private static final String ATTR_ACTIVE_CHAT_ID = "activeChatId";
+ private volatile Map<Long, Chat> anonymousChats = new ConcurrentHashMap<>();
- private static final String ATTR_ANONYMOUS_CHATS = "anonymousChats";
-
- private static final String ATTR_CHAT_INPUT = "chatInput";
+ private volatile String chatInput;
public WebSession(Request request) {
super(request);
@@ -53,119 +52,111 @@ public class WebSession extends org.apache.wicket.protocol.http.WebSession {
}
public void logout() {
- SecurityUtils.getSubject().logout();
+ SecurityUtils.getSubject().logout();
replaceSession();
}
-
+
+ @Override
+ public void replaceSession() {
+ super.replaceSession();
+ issueCursor = null;
+ buildCursor = null;
+ packCursor = null;
+ pullRequestCursor = null;
+ zoneId = null;
+ redirectUrlsAfterDelete.clear();
+ expandedProjectIds.clear();
+ chatVisible = false;
+ activeChatId = null;
+ anonymousChats.clear();
+ chatInput = null;
+ }
+
@Nullable
public Cursor getIssueCursor() {
- return (Cursor) getAttribute(ATTR_ISSUE_CURSOR);
+ return issueCursor;
}
@Nullable
public Cursor getBuildCursor() {
- return (Cursor) getAttribute(ATTR_BUILD_CURSOR);
+ return buildCursor;
}
- @Nullable
public Cursor getPackCursor() {
- return (Cursor) getAttribute(ATTR_PACK_CURSOR);
+ return packCursor;
}
@Nullable
public Cursor getPullRequestCursor() {
- return (Cursor) getAttribute(ATTR_PULL_REQUEST_CURSOR);
+ return pullRequestCursor;
}
public void setIssueCursor(@Nullable Cursor issueCursor) {
- setAttribute(ATTR_ISSUE_CURSOR, issueCursor);
+ this.issueCursor = issueCursor;
}
public void setBuildCursor(@Nullable Cursor buildCursor) {
- setAttribute(ATTR_BUILD_CURSOR, buildCursor);
+ this.buildCursor = buildCursor;
}
public void setPackCursor(@Nullable Cursor packCursor) {
- setAttribute(ATTR_PACK_CURSOR, packCursor);
+ this.packCursor = packCursor;
}
public void setPullRequestCursor(@Nullable Cursor pullRequestCursor) {
- setAttribute(ATTR_PULL_REQUEST_CURSOR, pullRequestCursor);
- }
-
- @SuppressWarnings("unchecked")
- private Map<Class<?>, String> getRedirectUrlsAfterDelete() {
- Map<Class<?>, String> map = (Map<Class<?>, String>) getAttribute(ATTR_REDIRECT_URLS_AFTER_DELETE);
- if (map == null) {
- map = new HashMap<>();
- setAttribute(ATTR_REDIRECT_URLS_AFTER_DELETE, (Serializable) map);
- }
- return map;
+ this.pullRequestCursor = pullRequestCursor;
}
@Nullable
public String getRedirectUrlAfterDelete(Class<?> clazz) {
- return getRedirectUrlsAfterDelete().get(clazz);
+ return redirectUrlsAfterDelete.get(clazz);
}
public void setRedirectUrlAfterDelete(Class<?> clazz, String redirectUrlAfterDelete) {
- getRedirectUrlsAfterDelete().put(clazz, redirectUrlAfterDelete);
+ redirectUrlsAfterDelete.put(clazz, redirectUrlAfterDelete);
}
- @SuppressWarnings("unchecked")
public Set<Long> getExpandedProjectIds() {
- Set<Long> set = (Set<Long>) getAttribute(ATTR_EXPANDED_PROJECT_IDS);
- if (set == null) {
- set = new HashSet<>();
- setAttribute(ATTR_EXPANDED_PROJECT_IDS, (Serializable) set);
- }
- return set;
+ return expandedProjectIds;
}
@Nullable
public ZoneId getZoneId() {
- return (ZoneId) getAttribute(ATTR_ZONE_ID);
+ return zoneId;
}
public void setZoneId(@Nullable ZoneId zoneId) {
- setAttribute(ATTR_ZONE_ID, zoneId);
+ this.zoneId = zoneId;
}
public boolean isChatVisible() {
- Boolean visible = (Boolean) getAttribute(ATTR_CHAT_VISIBLE);
- return visible != null && visible;
+ return chatVisible;
}
public void setChatVisible(boolean chatVisible) {
- setAttribute(ATTR_CHAT_VISIBLE, chatVisible);
+ this.chatVisible = chatVisible;
}
@Nullable
public Long getActiveChatId() {
- return (Long) getAttribute(ATTR_ACTIVE_CHAT_ID);
+ return activeChatId;
}
public void setActiveChatId(Long activeChatId) {
- setAttribute(ATTR_ACTIVE_CHAT_ID, activeChatId);
+ this.activeChatId = activeChatId;
}
- @SuppressWarnings("unchecked")
public Map<Long, Chat> getAnonymousChats() {
- Map<Long, Chat> map = (Map<Long, Chat>) getAttribute(ATTR_ANONYMOUS_CHATS);
- if (map == null) {
- map = new HashMap<>();
- setAttribute(ATTR_ANONYMOUS_CHATS, (Serializable) map);
- }
- return map;
+ return anonymousChats;
}
@Nullable
public String getChatInput() {
- return (String) getAttribute(ATTR_CHAT_INPUT);
+ return chatInput;
}
public void setChatInput(String chatInput) {
- setAttribute(ATTR_CHAT_INPUT, chatInput);
+ this.chatInput = chatInput;
}
public static WebSession from(HttpSession session) {
diff --git a/server-core/src/main/java/io/onedev/server/web/asset/icon/ai-summarize.svg b/server-core/src/main/java/io/onedev/server/web/asset/icon/ai-summarize.svg
deleted file mode 100644
index 2832245118..0000000000
--- a/server-core/src/main/java/io/onedev/server/web/asset/icon/ai-summarize.svg
+++ /dev/null
@@ -1 +0,0 @@
-<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1764891371306" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9180" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M789.333333 512V234.666667q0-42.666667-42.666666-42.666667H234.666667q-42.666667 0-42.666667 42.666667v554.666666q0 42.666667 42.666667 42.666667h298.666666a42.666667 42.666667 0 1 1 0 85.333333H234.666667q-53.013333 0-90.517334-37.482666Q106.666667 842.346667 106.666667 789.333333V234.666667q0-53.013333 37.482666-90.517334Q181.653333 106.666667 234.666667 106.666667h512q53.013333 0 90.517333 37.482666Q874.666667 181.653333 874.666667 234.666667v277.333333a42.666667 42.666667 0 1 1-85.333334 0zM490.666667 277.333333h-170.666667a42.666667 42.666667 0 1 0 0 85.333334h170.666667a42.666667 42.666667 0 1 0 0-85.333334z m213.333333 213.333334a42.666667 42.666667 0 0 0-42.666667-42.666667H320a42.666667 42.666667 0 1 0 0 85.333333h341.333333a42.666667 42.666667 0 0 0 42.666667-42.666666zM320 704h85.333333a42.666667 42.666667 0 1 0 0-85.333333h-85.333333a42.666667 42.666667 0 1 0 0 85.333333z m310.442667 79.36c-15.701333-4.202667-15.701333-26.517333 0-30.72l7.722666-2.090667a159.274667 159.274667 0 0 0 112.384-112.384l2.069334-7.722666c4.224-15.701333 26.538667-15.701333 30.762666 0l2.069334 7.722666a159.274667 159.274667 0 0 0 112.384 112.384l7.701333 2.069334c15.722667 4.224 15.722667 26.538667 0 30.762666l-7.68 2.069334a159.274667 159.274667 0 0 0-112.426667 112.384l-2.048 7.701333c-4.224 15.722667-26.538667 15.722667-30.762666 0l-2.069334-7.68a159.274667 159.274667 0 0 0-112.384-112.405333l-7.722666-2.069334z" p-id="9181"></path></svg>
\ No newline at end of file
diff --git a/server-core/src/main/java/io/onedev/server/web/asset/icon/ai2.svg b/server-core/src/main/java/io/onedev/server/web/asset/icon/ai2.svg
new file mode 100644
index 0000000000..d8e8f01682
--- /dev/null
+++ b/server-core/src/main/java/io/onedev/server/web/asset/icon/ai2.svg
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ t="1765593843440"
+ class="icon"
+ viewBox="0 0 1024 1024"
+ version="1.1"
+ p-id="34352"
+ width="200"
+ height="200"
+ id="svg1"
+ sodipodi:docname="ai2.svg"
+ inkscape:version="1.3.2 (091e20e, 2023-11-25)"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:svg="http://www.w3.org/2000/svg">
+ <defs
+ id="defs1" />
+ <sodipodi:namedview
+ id="namedview1"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:showpageshadow="2"
+ inkscape:pageopacity="0.0"
+ inkscape:pagecheckerboard="0"
+ inkscape:deskcolor="#d1d1d1"
+ inkscape:zoom="3.075"
+ inkscape:cx="100"
+ inkscape:cy="99.837398"
+ inkscape:window-width="1864"
+ inkscape:window-height="1027"
+ inkscape:window-x="60"
+ inkscape:window-y="25"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg1" />
+ <path
+ d="m 516.20415,55.362601 a 20.615808,21.112425 0 0 1 19.89717,15.868816 576.2545,590.13597 0 0 0 150.19447,269.815873 577.73668,591.65386 0 0 0 263.51404,153.85852 20.481064,20.974435 0 0 1 0,40.70695 576.43416,590.31995 0 0 0 -263.51404,153.85853 577.69177,591.60785 0 0 0 -122.52707,186.05612 c -11.40831,27.27596 -20.66072,55.14988 -27.6674,83.75974 a 20.436149,20.928438 0 0 1 -39.74944,0 A 576.34433,590.22796 0 0 0 346.1125,689.47129 577.87143,591.79184 0 0 0 164.38798,563.99265 541.67025,554.7186 0 0 0 82.643371,535.61276 a 20.481064,20.974435 0 0 1 0,-40.70695 A 578.05109,591.97583 0 0 0 346.1125,341.00129 577.24262,591.14789 0 0 0 496.35188,71.185421 20.481064,20.974435 0 0 1 516.15923,55.362601 Z m 0,207.766499 A 666.98202,683.04904 0 0 1 409.71159,405.99444 l -0.17966,0.18399 A 667.61083,683.69299 0 0 1 270.07206,515.23628 c 46.26205,27.13799 89.24533,59.93354 128.00665,97.69671 l 11.45322,11.40715 0.13475,0.138 c 41.68076,42.7768 77.4328,90.84322 106.49255,142.77335 A 667.74558,683.83097 0 0 1 622.74161,624.47814 l 0.13475,-0.138 A 666.17356,682.22109 0 0 1 762.33623,515.23628 667.38626,683.463 0 0 1 622.87636,406.17843 l -0.13475,-0.18399 A 665.94899,681.99112 0 0 1 516.20415,263.1291 Z"
+ p-id="34353"
+ id="path1"
+ style="stroke-width:1.06529" />
+ <path
+ d="m 933.71317,191.58166 a 165.1873,165.1873 0 0 0 -154.7468,154.74679 h -0.62022 A 165.15284,165.15284 0 0 0 623.59935,191.58166 v -0.62023 A 165.15284,165.15284 0 0 0 778.34615,36.214634 h 0.62022 a 165.1873,165.1873 0 0 0 154.7468,154.746796 z"
+ p-id="21723"
+ id="path1-8"
+ style="stroke-width:0.403794" />
+</svg>
diff --git a/server-core/src/main/java/io/onedev/server/web/component/ai/chat/ChatPanel.html b/server-core/src/main/java/io/onedev/server/web/component/ai/chat/ChatPanel.html
index f8cfc10643..753eb762c6 100644
--- a/server-core/src/main/java/io/onedev/server/web/component/ai/chat/ChatPanel.html
+++ b/server-core/src/main/java/io/onedev/server/web/component/ai/chat/ChatPanel.html
@@ -20,7 +20,7 @@
</li>
</ul>
<form wicket:id="send" class="send flex-shrink-0 position-relative">
- <textarea wicket:id="input" class="form-control" t:placeholder="Type your message here"></textarea>
+ <textarea wicket:id="input" class="form-control" t:placeholder="Type your message here (SHIFT+ENTER to start new line)"></textarea>
<a wicket:id="submit" class="submit position-absolute btn btn-primary btn-icon btn-sm" t:data-tippy-content="Send"><wicket:svg href="arrow2" class="icon rotate-270"></wicket:svg></a>
<a wicket:id="stop" class="stop position-absolute btn btn-primary btn-icon btn-sm" t:data-tippy-content="Stop"><wicket:svg href="stop" class="icon"></wicket:svg></a>
</form>
diff --git a/server-core/src/main/java/io/onedev/server/web/component/ai/chat/ChatPanel.java b/server-core/src/main/java/io/onedev/server/web/component/ai/chat/ChatPanel.java
index b2d798d8aa..ad484648e6 100644
--- a/server-core/src/main/java/io/onedev/server/web/component/ai/chat/ChatPanel.java
+++ b/server-core/src/main/java/io/onedev/server/web/component/ai/chat/ChatPanel.java
@@ -318,7 +318,7 @@ public class ChatPanel extends Panel {
@Override
public String getObject() {
var responding = getResponding();
- if (responding != null)
+ if (responding != null)
return responding.getContent();
else
return null;
diff --git a/server-core/src/main/java/io/onedev/server/web/component/ai/chat/chat.css b/server-core/src/main/java/io/onedev/server/web/component/ai/chat/chat.css
index 95e153db85..9a875780be 100644
--- a/server-core/src/main/java/io/onedev/server/web/component/ai/chat/chat.css
+++ b/server-core/src/main/java/io/onedev/server/web/component/ai/chat/chat.css
@@ -20,7 +20,7 @@
cursor: col-resize;
z-index: 10;
background: var(--light) url(/~icon/grip3.svg) no-repeat scroll center center;
- background-size: 18px 18px;
+ background-size: 18px 18px;
}
.dark-mode .chat .ui-resizable-handle {
@@ -80,6 +80,7 @@
padding: 0.7rem;
border-radius: 0.42rem;
margin-left: 3rem;
+ word-break: break-word;
}
.dark-mode .chat>.body>.messages>.request>div {
background: var(--dark-mode-light-dark);
diff --git a/server-core/src/main/java/io/onedev/server/web/component/diff/blob/BlobAnnotationSupport.java b/server-core/src/main/java/io/onedev/server/web/component/diff/blob/BlobAnnotationSupport.java
index 9b930634e2..624182f43a 100644
--- a/server-core/src/main/java/io/onedev/server/web/component/diff/blob/BlobAnnotationSupport.java
+++ b/server-core/src/main/java/io/onedev/server/web/component/diff/blob/BlobAnnotationSupport.java
@@ -42,6 +42,8 @@ public interface BlobAnnotationSupport extends Serializable {
void onAddComment(AjaxRequestTarget target, DiffPlanarRange commentRange);
+ void onMark(AjaxRequestTarget target, DiffPlanarRange markRange);
+
Component getCommentContainer();
}
diff --git a/server-core/src/main/java/io/onedev/server/web/component/diff/blob/text/BlobTextDiffPanel.java b/server-core/src/main/java/io/onedev/server/web/component/diff/blob/text/BlobTextDiffPanel.java
index 4a5eb7900b..1286b43357 100644
--- a/server-core/src/main/java/io/onedev/server/web/component/diff/blob/text/BlobTextDiffPanel.java
+++ b/server-core/src/main/java/io/onedev/server/web/component/diff/blob/text/BlobTextDiffPanel.java
@@ -41,6 +41,7 @@ import com.ibm.icu.text.SpoofChecker;
import io.onedev.commons.utils.LinearRange;
import io.onedev.commons.utils.StringUtils;
import io.onedev.server.OneDev;
+import io.onedev.server.ai.HighlightedTextTool;
import io.onedev.server.codequality.CodeProblem;
import io.onedev.server.git.BlameBlock;
import io.onedev.server.git.BlameCommit;
@@ -53,6 +54,7 @@ import io.onedev.server.model.PullRequest;
import io.onedev.server.search.code.hit.QueryHit;
import io.onedev.server.security.SecurityUtils;
import io.onedev.server.service.CodeCommentService;
+import io.onedev.server.service.support.ChatTool;
import io.onedev.server.util.DateUtils;
import io.onedev.server.util.Pair;
import io.onedev.server.util.diff.DiffBlock;
@@ -68,13 +70,16 @@ import io.onedev.server.web.component.svg.SpriteImage;
import io.onedev.server.web.component.symboltooltip.SymbolContext;
import io.onedev.server.web.component.symboltooltip.SymbolTooltipPanel;
import io.onedev.server.web.page.base.BasePage;
+import io.onedev.server.web.page.layout.LayoutPage;
import io.onedev.server.web.page.project.blob.ProjectBlobPage;
import io.onedev.server.web.page.project.commits.CommitDetailPage;
import io.onedev.server.web.util.AnnotationInfo;
+import io.onedev.server.web.util.ChatToolAware;
import io.onedev.server.web.util.CodeCommentInfo;
import io.onedev.server.web.util.DiffPlanarRange;
+import io.onedev.server.web.util.WicketUtils;
-public class BlobTextDiffPanel extends Panel {
+public class BlobTextDiffPanel extends Panel implements ChatToolAware {
private final BlobChange change;
@@ -315,6 +320,15 @@ public class BlobTextDiffPanel extends Panel {
case "setActive":
onActive(target);
break;
+ case "explainSelection":
+ var range = getRange(params, "param1", "param2", "param3", "param4", "param5");
+ getAnnotationSupport().onMark(target, range);
+ var page = (LayoutPage) getPage();
+ page.getChatter().show(target, "Help me understand highlighted text. Display in " + getSession().getLocale().getDisplayLanguage());
+ script = String.format("onedev.server.blobTextDiff.mark($('#%s'), %s);",
+ getMarkupId(), convertToJson(range));
+ target.appendJavaScript(script);
+ break;
}
}
@@ -367,8 +381,8 @@ public class BlobTextDiffPanel extends Panel {
}
@Override
- protected SymbolContext getSymbolContext(String symbolPosition, int beforeContextSize,
- int afterContextSize, int atStartContextSize) {
+ protected SymbolContext getSymbolContext(String symbolPosition, String symbolBegin, String symbolEnd,
+ String truncationMark, int atStartContextSize, int beforeContextSize, int afterContextSize) {
String[] parts = symbolPosition.split(":");
boolean isNew = parts[0].equals("new");
int lineNo = Integer.parseInt(parts[1]);
@@ -385,7 +399,6 @@ public class BlobTextDiffPanel extends Panel {
List<String> linesBefore = new ArrayList<>();
List<String> linesAfter = new ArrayList<>();
- String symbolLine = lines.get(lineNo);
for (int i = Math.max(0, lineNo - beforeContextSize); i < lineNo; i++) {
linesBefore.add(lines.get(i));
@@ -399,13 +412,7 @@ public class BlobTextDiffPanel extends Panel {
linesAtStart.add(lines.get(i));
}
- return new SymbolContext(
- path,
- symbolLine,
- linesBefore,
- linesAfter,
- linesAtStart
- );
+ return new SymbolContext(path, linesBefore);
}
};
@@ -478,10 +485,17 @@ public class BlobTextDiffPanel extends Panel {
translations.put("show-comment", _T("Click to show comment of marked text"));
translations.put("loading", _T("Loading..."));
translations.put("invalid-selection", _T("Invalid selection, click for details"));
+ var page = (LayoutPage) getPage();
+ if (getAnnotationSupport() != null
+ && WicketUtils.isSubscriptionActive()
+ && !page.getChatter().getEntitledAis().isEmpty()) {
+ translations.put("explain-selection", _T("Explain selected text with AI"));
+ }
for (var severity: CodeProblem.Severity.values())
translations.put(severity.name(), _T("severity:" + severity.name()));
translations.put("add-problem-comment", _T("Add comment"));
+ var jsonOfMarkRange = convertToJson(markRange);
String script = String.format("onedev.server.blobTextDiff.onDomReady('%s', '%s', '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s);",
getMarkupId(), symbolTooltip.getMarkupId(),
change.getOldBlobIdent().revision,
@@ -489,18 +503,15 @@ public class BlobTextDiffPanel extends Panel {
change.getOldBlobIdent().path!=null? escapeJavaScript(change.getOldBlobIdent().path):"",
change.getNewBlobIdent().path!=null? escapeJavaScript(change.getNewBlobIdent().path):"",
callback, blameMessageBehavior.getCallback(),
- convertToJson(markRange), convertToJson(openCommentInfo),
+ jsonOfMarkRange, convertToJson(openCommentInfo),
convertToJson(annotationInfoModel.getObject()),
commentContainerId, convertToJson(translations));
response.render(OnDomReadyHeaderItem.forScript(script));
- String jsonOfMarkRange;
- if (RequestCycle.get().find(AjaxRequestTarget.class) == null && markRange != null)
- jsonOfMarkRange = convertToJson(markRange);
- else
- jsonOfMarkRange = "undefined";
- script = String.format("onedev.server.blobTextDiff.onLoad('%s', %s);", getMarkupId(), jsonOfMarkRange);
+ script = String.format("onedev.server.blobTextDiff.onLoad('%s', %s);",
+ getMarkupId(),
+ RequestCycle.get().find(AjaxRequestTarget.class) == null? jsonOfMarkRange: "null");
response.render(OnLoadHeaderItem.forScript(script));
}
@@ -1074,6 +1085,27 @@ public class BlobTextDiffPanel extends Panel {
private boolean isConfusable(String text1, String text2) {
return confusableChecker.areConfusable(text1, text2) != 0;
}
+
+ @Override
+ public List<ChatTool> getChatTools() {
+ var tools = new ArrayList<ChatTool>();
+ if (getAnnotationSupport() != null) {
+ var markRange = getAnnotationSupport().getMarkRange();
+ if (markRange != null) {
+ String fileName;
+ List<String> fileLines;
+ if (markRange.isLeftSide()) {
+ fileName = change.getOldBlobIdent().getName();
+ fileLines = change.getOldText().getLines();
+ } else {
+ fileName = change.getNewBlobIdent().getName();
+ fileLines = change.getNewText().getLines();
+ }
+ tools.add(new HighlightedTextTool(fileName, fileLines, markRange));
+ }
+ }
+ return tools;
+ }
private static class BlameInfo implements Serializable {
diff --git a/server-core/src/main/java/io/onedev/server/web/component/diff/blob/text/blob-text-diff.js b/server-core/src/main/java/io/onedev/server/web/component/diff/blob/text/blob-text-diff.js
index af96541c0a..de5c88d30f 100644
--- a/server-core/src/main/java/io/onedev/server/web/component/diff/blob/text/blob-text-diff.js
+++ b/server-core/src/main/java/io/onedev/server/web/component/diff/blob/text/blob-text-diff.js
@@ -480,7 +480,7 @@ onedev.server.blobTextDiff = {
if (markRange) {
$container.data("markRange", markRange);
onedev.server.blobTextDiff.mark($container, markRange);
- }
+ }
},
onLoad: function(containerId, markRange) {
var $container = $("#" + containerId);
@@ -785,6 +785,17 @@ onedev.server.blobTextDiff = {
clipboard.destroy();
$(".selection-popover").remove();
});
+ var explainSelectionText = onedev.server.blobTextDiff.translations["explain-selection"];
+ if (explainSelectionText) {
+ var svg = `<svg class='icon mr-1'><use xlink:href='${onedev.server.icons}#ai2'/></svg>`;
+ $content.append(`<a class='explain-selection'>${svg} ${explainSelectionText}</a>`);
+ $content.children("a.explain-selection").click(function() {
+ $(".selection-popover").remove();
+ $container.data("callback")("explainSelection", markRange.leftSide,
+ markRange.fromRow, markRange.fromColumn, markRange.toRow, markRange.toColumn);
+ });
+ }
+
if (loggedIn) {
$content.append(`<a class='comment'><svg class='icon mr-1'><use xlink:href='${onedev.server.icons}#comment'/></svg> ${onedev.server.blobTextDiff.translations["add-selection-comment"]}</a>`);
$content.children("a.comment").click(function() {
@@ -796,9 +807,9 @@ onedev.server.blobTextDiff = {
} else {
var loginHref = $(".sign-in").attr("href");
$content.append(`<a class='comment' href='${loginHref}'><svg class='icon mr-1'><use xlink:href='${onedev.server.icons}#warning'/></svg> ${onedev.server.blobTextDiff.translations["login-to-comment"]}</a>`);
- }
- }
-
+ }
+ }
+
$container.selectionPopover("open", {
position: position,
content: $content
diff --git a/server-core/src/main/java/io/onedev/server/web/component/diff/revision/RevisionDiffPanel.java b/server-core/src/main/java/io/onedev/server/web/component/diff/revision/RevisionDiffPanel.java
index 30583d100a..4892493d22 100644
--- a/server-core/src/main/java/io/onedev/server/web/component/diff/revision/RevisionDiffPanel.java
+++ b/server-core/src/main/java/io/onedev/server/web/component/diff/revision/RevisionDiffPanel.java
@@ -841,6 +841,12 @@ public abstract class RevisionDiffPanel extends Panel {
((BasePage)getPage()).resizeWindow(target);
}
+ @Override
+ public void onMark(AjaxRequestTarget target, DiffPlanarRange markRange) {
+ var mark = change.getMark(markRange);
+ annotationSupport.onMark(target, mark);
+ };
+
@Override
public void onAddComment(AjaxRequestTarget target, DiffPlanarRange commentRange) {
Mark mark = change.getMark(commentRange);
@@ -2068,6 +2074,12 @@ public abstract class RevisionDiffPanel extends Panel {
((BasePage)getPage()).resizeWindow(target);
}
+ @Override
+ public void onMark(AjaxRequestTarget target, DiffPlanarRange markRange) {
+ Mark mark = change.getMark(markRange);
+ annotationSupport.onMark(target, mark);
+ }
+
@Override
public void onAddComment(AjaxRequestTarget target, DiffPlanarRange commentRange) {
Mark mark = change.getMark(commentRange);
diff --git a/server-core/src/main/java/io/onedev/server/web/component/issue/activities/IssueActivitiesPanel.html b/server-core/src/main/java/io/onedev/server/web/component/issue/activities/IssueActivitiesPanel.html
index ceb946a89a..e7289a04f4 100644
--- a/server-core/src/main/java/io/onedev/server/web/component/issue/activities/IssueActivitiesPanel.html
+++ b/server-core/src/main/java/io/onedev/server/web/component/issue/activities/IssueActivitiesPanel.html
@@ -18,7 +18,7 @@
</form>
</wicket:fragment>
<wicket:fragment wicket:id="optionsFrag">
- <a wicket:id="aiSummarize" t:data-tippy-content="Summarize comments with AI" class="btn btn-xs btn-outline-secondary btn-hover-primary btn-icon"><wicket:svg href="ai-summarize" class="icon"></wicket:svg></a>
+ <a wicket:id="aiSummarize" t:data-tippy-content="Summarize comments with AI" class="btn btn-xs btn-outline-secondary btn-hover-primary btn-icon"><wicket:svg href="ai2" class="icon"></wicket:svg></a>
<div class="btn-group">
<a wicket:id="showComments" t:data-tippy-content="Toggle comments" class="btn btn-xs text-muted btn-outline-secondary btn-active-secondary btn-icon"><wicket:svg href="comments" class="icon"></wicket:svg></a>
<a wicket:id="showChangeHistory" t:data-tippy-content="Toggle change history" class="btn btn-xs text-muted btn-outline-secondary btn-active-secondary btn-icon"><wicket:svg href="history" class="icon"></wicket:svg></a>
diff --git a/server-core/src/main/java/io/onedev/server/web/component/issue/activities/IssueActivitiesPanel.java b/server-core/src/main/java/io/onedev/server/web/component/issue/activities/IssueActivitiesPanel.java
index a1e0de5adc..f009ebb2bf 100644
--- a/server-core/src/main/java/io/onedev/server/web/component/issue/activities/IssueActivitiesPanel.java
+++ b/server-core/src/main/java/io/onedev/server/web/component/issue/activities/IssueActivitiesPanel.java
@@ -334,7 +334,7 @@ public abstract class IssueActivitiesPanel extends Panel {
@Override
public void onClick(AjaxRequestTarget target) {
var page = (LayoutPage)getPage();
- page.getChatter().show(target, "Summarize comments of current issue. Display summary in " + getSession().getLocale().getDisplayLanguage());
+ page.getChatter().show(target, "Summarize comments of current issue. Display in " + getSession().getLocale().getDisplayLanguage());
}
@Override
diff --git a/server-core/src/main/java/io/onedev/server/web/component/symboltooltip/SymbolContext.java b/server-core/src/main/java/io/onedev/server/web/component/symboltooltip/SymbolContext.java
index 92824803ff..88b5e94ca0 100644
--- a/server-core/src/main/java/io/onedev/server/web/component/symboltooltip/SymbolContext.java
+++ b/server-core/src/main/java/io/onedev/server/web/component/symboltooltip/SymbolContext.java
@@ -9,41 +9,19 @@ public class SymbolContext implements Serializable {
private final String blobPath;
- private final String symbolLine;
+ private final List<String> contextLines;
- private final List<String> linesBeforeSymbolLine;
-
- private final List<String> linesAfterSymbolLine;
-
- private final List<String> linesAtStart;
-
- public SymbolContext(String blobPath, String symbolLine,
- List<String> linesBeforeSymbolLine, List<String> linesAfterSymbolLine, List<String> linesAtStart) {
+ public SymbolContext(String blobPath, List<String> contextLines) {
this.blobPath = blobPath;
- this.symbolLine = symbolLine;
- this.linesBeforeSymbolLine = linesBeforeSymbolLine;
- this.linesAfterSymbolLine = linesAfterSymbolLine;
- this.linesAtStart = linesAtStart;
+ this.contextLines = contextLines;
}
public String getBlobPath() {
return blobPath;
}
- public String getSymbolLine() {
- return symbolLine;
- }
-
- public List<String> getLinesBeforeSymbolLine() {
- return linesBeforeSymbolLine;
- }
-
- public List<String> getLinesAfterSymbolLine() {
- return linesAfterSymbolLine;
- }
-
- public List<String> getLinesAtStart() {
- return linesAtStart;
+ public List<String> getContextLines() {
+ return contextLines;
}
}
diff --git a/server-core/src/main/java/io/onedev/server/web/component/symboltooltip/SymbolTooltipPanel.java b/server-core/src/main/java/io/onedev/server/web/component/symboltooltip/SymbolTooltipPanel.java
index 8e693d43ea..e29881e6a8 100644
--- a/server-core/src/main/java/io/onedev/server/web/component/symboltooltip/SymbolTooltipPanel.java
+++ b/server-core/src/main/java/io/onedev/server/web/component/symboltooltip/SymbolTooltipPanel.java
@@ -36,6 +36,7 @@ import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.annotation.JsonIgnoreType;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Joiner;
import dev.langchain4j.data.message.SystemMessage;
import dev.langchain4j.data.message.UserMessage;
@@ -72,6 +73,12 @@ public abstract class SymbolTooltipPanel extends Panel {
private static final int AT_START_CONTEXT_SIZE = 200;
+ private static final String SYMBOL_BEGIN = "[SYMBOL_BEGIN]";
+
+ private static final String SYMBOL_END = "[SYMBOL_END]";
+
+ private static final String OMITTED_LINES = "...OMITTED LINES...";
+
private static final Logger logger = LoggerFactory.getLogger(SymbolTooltipPanel.class);
private String revision = "";
@@ -334,30 +341,33 @@ public abstract class SymbolTooltipPanel extends Panel {
mapperCopy.addMixIn(LinearRange.class, IgnoreLinearRangeMixin.class);
var jsonOfSymbolHits = mapperCopy.writeValueAsString(symbolHits);
- var symbolContext = getSymbolContext(symbolPosition, BEFORE_CONTEXT_SIZE,
- AFTER_CONTEXT_SIZE, AT_START_CONTEXT_SIZE);
- var jsonOfSymbolContext = mapperCopy.writeValueAsString(symbolContext);
+ var symbolContext = getSymbolContext(symbolPosition, SYMBOL_BEGIN, SYMBOL_END, OMITTED_LINES,
+ AT_START_CONTEXT_SIZE, BEFORE_CONTEXT_SIZE, AFTER_CONTEXT_SIZE);
+ var occurrenceMap = Map.of(
+ "symbolName", symbolName,
+ "blobPath", symbolContext.getBlobPath(),
+ "symbolContext", Joiner.on('\n').join(symbolContext.getContextLines()),
+ "note", String.format("Symbol is between %s and %s in the context", SYMBOL_BEGIN, SYMBOL_END)
+ );
+ var jsonOfSymbolOccurrence = mapperCopy.writeValueAsString(occurrenceMap);
var systemMessage = new SystemMessage("""
- You are familiar with various programming languages. Given a symbol name, a json object of
- symbol context, and a json array of possible symbol definitions, please determine the most
- likely symbol definition and return its index in the array. Symbol definition may contain
- parent symbol, and this is where the symbol is defined inside (namespace, package etc).
- The @type property in symbol definition means category/kind of the symbol (type, method,
- variable etc).
+ You are familiar with various programming languages. Given a json object of symbol
+ occurrence information, and a json array of possible symbol definitions, please
+ determine the most likely definition for occurred symbol and return its index in
+ the array. Symbol definition may contain parent symbol, and this is where the
+ symbol is defined inside (namespace, package etc). The @type property in symbol
+ definition means category/kind of the symbol (type, method, variable etc).
IMPORTANT: only return index of the definition, no other text or comments.
""");
var userMessage = new UserMessage(String.format("""
- Symbol name:
- %s
-
- Symbol context json:
+ Symbol occurrence information json:
%s
Possible symbol definitions json:
%s
- """, symbolName, jsonOfSymbolContext, jsonOfSymbolHits));
+ """, symbolName, jsonOfSymbolOccurrence, jsonOfSymbolHits));
index = Integer.parseInt(liteModel.chat(systemMessage, userMessage).aiMessage().text());
if (index < 0 || index >= symbolHits.size())
Session.get().warn("Unable to find most likely definition");
@@ -427,8 +437,8 @@ public abstract class SymbolTooltipPanel extends Panel {
protected abstract String getSymbolPositionCalcFunction();
- protected abstract SymbolContext getSymbolContext(String symbolPosition, int beforeContextSize,
- int afterContextSize, int atStartContextSize);
+ protected abstract SymbolContext getSymbolContext(String symbolPosition, String symbolBegin, String symbolEnd,
+ String truncationMark, int atStartContextSize, int beforeContextSize, int afterContextSize);
}
diff --git a/server-core/src/main/java/io/onedev/server/web/page/base/BasePage.java b/server-core/src/main/java/io/onedev/server/web/page/base/BasePage.java
index 2d42ec7c0f..ad02f6ac3c 100644
--- a/server-core/src/main/java/io/onedev/server/web/page/base/BasePage.java
+++ b/server-core/src/main/java/io/onedev/server/web/page/base/BasePage.java
@@ -334,8 +334,9 @@ public abstract class BasePage extends WebPage {
for (ChangeObserver observer: findChangeObservers()) {
Collection<String> observingChangedObservables =
filterObservables(observer.getObservables(), observables);
- if (!observingChangedObservables.isEmpty())
+ if (!observingChangedObservables.isEmpty()) {
observer.onObservableChanged(handler, observingChangedObservables);
+ }
}
}
diff --git a/server-core/src/main/java/io/onedev/server/web/page/base/base.css b/server-core/src/main/java/io/onedev/server/web/page/base/base.css
index 2dd3f75ca4..50f6b43982 100644
--- a/server-core/src/main/java/io/onedev/server/web/page/base/base.css
+++ b/server-core/src/main/java/io/onedev/server/web/page/base/base.css
@@ -223,7 +223,9 @@ a.tree-junction {
position: fixed;
max-width: 75%;
font-weight: bold;
- top: 0;
+ top: 0;
+ left: 50%;
+ transform: translateX(-50%);
background: var(--light-danger);
border-radius: 0 0 0.42rem 0.42rem;
color: var(--danger);
diff --git a/server-core/src/main/java/io/onedev/server/web/page/base/base.js b/server-core/src/main/java/io/onedev/server/web/page/base/base.js
index 861637860d..f804b51506 100644
--- a/server-core/src/main/java/io/onedev/server/web/page/base/base.js
+++ b/server-core/src/main/java/io/onedev/server/web/page/base/base.js
@@ -345,11 +345,7 @@ onedev.server = {
$(window).on("beforeunload", function() {
pageUnloading = true;
});
-
- function showError($error) {
- $error.css("left", ($(window).width()-$error.outerWidth()) / 2);
- $error.slideDown("slow");
- }
+
function testConnection() {
if (Wicket.WebSocket.INSTANCE.ws && Wicket.WebSocket.INSTANCE.ws.readyState == WebSocket.OPEN) {
Wicket.WebSocket.send("TestConnection");
@@ -362,17 +358,17 @@ onedev.server = {
});
Wicket.Event.subscribe("/websocket/closed", function(jqEvent) {
if (!pageUnloading) {
- showError($(".connection-error"));
+ $(".connection-error").show();
}
});
Wicket.Event.subscribe("/websocket/error", function(jqEvent) {
if (!pageUnloading) {
- showError($(".connection-error"));
+ $(".connection-error").show();
}
});
Wicket.Event.subscribe("/websocket/message", function(jqEvent, message) {
if (message == "ErrorMessage")
- showError($(".page-error"));
+ $(".page-error").slideDown("slow");
});
},
diff --git a/server-core/src/main/java/io/onedev/server/web/page/project/blob/render/BlobRenderContext.java b/server-core/src/main/java/io/onedev/server/web/page/project/blob/render/BlobRenderContext.java
index 0563c151cd..9af073b244 100644
--- a/server-core/src/main/java/io/onedev/server/web/page/project/blob/render/BlobRenderContext.java
+++ b/server-core/src/main/java/io/onedev/server/web/page/project/blob/render/BlobRenderContext.java
@@ -101,7 +101,7 @@ public interface BlobRenderContext extends Serializable {
void onCommentClosed(AjaxRequestTarget target);
void onAddComment(AjaxRequestTarget target, PlanarRange range);
-
+
ObjectId uploadFiles(FileUpload upload, @Nullable String directory, String commitMessage);
@Nullable
diff --git a/server-core/src/main/java/io/onedev/server/web/page/project/blob/render/source/SourceViewPanel.java b/server-core/src/main/java/io/onedev/server/web/page/project/blob/render/source/SourceViewPanel.java
index f10f6a1ea3..9e8ee992cf 100644
--- a/server-core/src/main/java/io/onedev/server/web/page/project/blob/render/source/SourceViewPanel.java
+++ b/server-core/src/main/java/io/onedev/server/web/page/project/blob/render/source/SourceViewPanel.java
@@ -13,6 +13,7 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
+import javax.inject.Inject;
import javax.servlet.http.Cookie;
import org.apache.wicket.Component;
@@ -57,16 +58,19 @@ import org.unbescape.html.HtmlEscape;
import org.unbescape.javascript.JavaScriptEscape;
import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
+import dev.langchain4j.agent.tool.ToolSpecification;
import io.onedev.commons.jsymbol.Symbol;
import io.onedev.commons.jsymbol.SymbolExtractor;
import io.onedev.commons.jsymbol.SymbolExtractorRegistry;
import io.onedev.commons.utils.LinearRange;
import io.onedev.commons.utils.PlanarRange;
import io.onedev.commons.utils.StringUtils;
-import io.onedev.server.OneDev;
+import io.onedev.server.ai.HighlightedTextTool;
import io.onedev.server.attachment.ProjectAttachmentSupport;
import io.onedev.server.codequality.BlobTarget;
import io.onedev.server.codequality.CodeProblem;
@@ -92,6 +96,7 @@ import io.onedev.server.service.BuildService;
import io.onedev.server.service.CodeCommentReplyService;
import io.onedev.server.service.CodeCommentService;
import io.onedev.server.service.CodeCommentStatusChangeService;
+import io.onedev.server.service.support.ChatTool;
import io.onedev.server.util.DateUtils;
import io.onedev.server.util.Similarities;
import io.onedev.server.util.diff.DiffUtils;
@@ -117,6 +122,7 @@ import io.onedev.server.web.component.suggestionapply.SuggestionApplyModalPanel;
import io.onedev.server.web.component.svg.SpriteImage;
import io.onedev.server.web.component.symboltooltip.SymbolContext;
import io.onedev.server.web.component.symboltooltip.SymbolTooltipPanel;
+import io.onedev.server.web.page.layout.LayoutPage;
import io.onedev.server.web.page.project.blob.render.BlobRenderContext;
import io.onedev.server.web.page.project.blob.render.BlobRenderContext.Mode;
import io.onedev.server.web.page.project.blob.render.BlobRenderer;
@@ -125,6 +131,7 @@ import io.onedev.server.web.page.project.blob.render.view.Positionable;
import io.onedev.server.web.page.project.blob.search.SearchMenuContributor;
import io.onedev.server.web.page.project.commits.CommitDetailPage;
import io.onedev.server.web.util.AnnotationInfo;
+import io.onedev.server.web.util.ChatToolAware;
import io.onedev.server.web.util.CodeCommentInfo;
import io.onedev.server.web.util.WicketUtils;
@@ -134,7 +141,7 @@ import io.onedev.server.web.util.WicketUtils;
* @author robin
*
*/
-public class SourceViewPanel extends BlobViewPanel implements Positionable, SearchMenuContributor {
+public class SourceViewPanel extends BlobViewPanel implements Positionable, SearchMenuContributor, ChatToolAware {
private static final Logger logger = LoggerFactory.getLogger(SourceViewPanel.class);
@@ -143,6 +150,33 @@ public class SourceViewPanel extends BlobViewPanel implements Positionable, Sear
private static final String COOKIE_OUTLINE_WIDTH = "sourceView.outline.width";
private static final String COOKIE_COMMENT_WIDTH = "sourceView.comment.width";
+
+ @Inject
+ private ObjectMapper objectMapper;
+
+ @Inject
+ private CodeCommentService codeCommentService;
+
+ @Inject
+ private BuildService buildService;
+
+ @Inject
+ private CodeSearchService searchService;
+
+ @Inject
+ private Set<CodeProblemContribution> codeProblemContributions;
+
+ @Inject
+ private Set<LineCoverageContribution> lineCoverageContributions;
+
+ @Inject
+ private GitService gitService;
+
+ @Inject
+ private CodeCommentReplyService codeCommentReplyService;
+
+ @Inject
+ private CodeCommentStatusChangeService codeCommentStatusChangeService;
private final List<Symbol> symbols = new ArrayList<>();
@@ -154,17 +188,15 @@ public class SourceViewPanel extends BlobViewPanel implements Positionable, Sear
RevCommit commitId = context.getCommit();
String path = context.getBlobIdent().path;
- CodeCommentService codeCommentService = OneDev.getInstance(CodeCommentService.class);
Map<CodeComment, PlanarRange> comments = codeCommentService.queryInHistory(project, commitId, path);
var problems = new HashSet<CodeProblem>();
Map<Integer, CoverageStatus> coverages = new HashMap<>();
var lines = context.getProject().getBlob(context.getBlobIdent(), true).getText().getLines();
- BuildService buildService = OneDev.getInstance(BuildService.class);
for (var build: buildService.query(project, commitId, null, null, null, null, new HashMap<>())) {
- for (var contribution: OneDev.getExtensions(CodeProblemContribution.class))
+ for (var contribution: codeProblemContributions)
problems.addAll(contribution.getCodeProblems(build, path, context.getProblemReport()));
- for (var contribution: OneDev.getExtensions(LineCoverageContribution.class)) {
+ for (var contribution: lineCoverageContributions) {
contribution.getLineCoverages(build, path, context.getCoverageReport()).forEach((key, value)->{
coverages.merge(key, value, CoverageStatus::mergeWith);
});
@@ -202,7 +234,6 @@ public class SourceViewPanel extends BlobViewPanel implements Positionable, Sear
String blobName = context.getBlobIdent().getName();
SymbolExtractor<Symbol> extractor = SymbolExtractorRegistry.getExtractor(blobName);
if (extractor != null) {
- CodeSearchService searchService = OneDev.getInstance(CodeSearchService.class);
List<Symbol> cachedSymbols = searchService.getSymbols(context.getProject(), blob.getBlobId(),
blob.getIdent().path);
if (cachedSymbols != null) {
@@ -278,7 +309,7 @@ public class SourceViewPanel extends BlobViewPanel implements Positionable, Sear
private String convertToJson(Object obj) {
try {
- return OneDev.getInstance(ObjectMapper.class).writeValueAsString(obj);
+ return objectMapper.writeValueAsString(obj);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
@@ -434,7 +465,7 @@ public class SourceViewPanel extends BlobViewPanel implements Positionable, Sear
@Override
protected void onSaveComment(AjaxRequestTarget target, CodeComment comment) {
- OneDev.getInstance(CodeCommentService.class).update(comment);
+ codeCommentService.update(comment);
target.add(commentContainer.get("head"));
}
@@ -481,6 +512,13 @@ public class SourceViewPanel extends BlobViewPanel implements Positionable, Sear
convertToJson(range), context.getPositionUrl(position), SecurityUtils.getAuthUser()!=null);
target.appendJavaScript(script);
break;
+ case "explainSelection":
+ range = getRange(params, "param1", "param2", "param3", "param4");
+ context.onPosition(target, BlobRenderer.getSourcePosition(range));
+ var page = (LayoutPage) getPage();
+ page.getChatter().show(target, "Help me understand highlighted text of current file. Display in " + getSession().getLocale().getDisplayLanguage());
+ target.appendJavaScript(String.format("onedev.server.sourceView.mark(%s, false);", convertToJson(range)));
+ break;
case "addComment":
Preconditions.checkNotNull(SecurityUtils.getAuthUser());
range = getRange(params, "param1", "param2", "param3", "param4");
@@ -594,7 +632,7 @@ public class SourceViewPanel extends BlobViewPanel implements Positionable, Sear
comment.setProject(context.getProject());
comment.setCompareContext(getCompareContext());
- OneDev.getInstance(CodeCommentService.class).create(comment);
+ codeCommentService.create(comment);
CodeCommentPanel commentPanel = new CodeCommentPanel(fragment.getId(), comment.getId()) {
@@ -605,7 +643,7 @@ public class SourceViewPanel extends BlobViewPanel implements Positionable, Sear
@Override
protected void onSaveComment(AjaxRequestTarget target, CodeComment comment) {
- OneDev.getInstance(CodeCommentService.class).update(comment);
+ codeCommentService.update(comment);
target.add(commentContainer.get("head"));
}
@@ -663,7 +701,7 @@ public class SourceViewPanel extends BlobViewPanel implements Positionable, Sear
@Override
protected void onSaveComment(AjaxRequestTarget target, CodeComment comment) {
- OneDev.getInstance(CodeCommentService.class).update(comment);
+ codeCommentService.update(comment);
target.add(commentContainer.get("head"));
}
@@ -692,7 +730,7 @@ public class SourceViewPanel extends BlobViewPanel implements Positionable, Sear
commentContainer.setVisible(true);
target.add(commentContainer);
- CodeComment comment = OneDev.getInstance(CodeCommentService.class).load(commentId);
+ CodeComment comment = codeCommentService.load(commentId);
script = String.format("onedev.server.sourceView.onCommentOpened(%s);",
convertToJson(new CodeCommentInfo(comment, range)));
target.appendJavaScript(script);
@@ -847,44 +885,56 @@ public class SourceViewPanel extends BlobViewPanel implements Positionable, Sear
return
"""
function(symbolEl) {
+ function getNodeText(node) {
+ if (node.nodeType === Node.TEXT_NODE) {
+ return node.textContent;
+ } else if (node.nodeType === Node.ELEMENT_NODE) {
+ if (node.classList && node.classList.contains('cm-tab')) {
+ return '\\t';
+ }
+ var text = '';
+ for (var i = 0; i < node.childNodes.length; i++) {
+ text += getNodeText(node.childNodes[i]);
+ }
+ return text;
+ }
+ return '';
+ }
+
var cm = symbolEl.closest(".CodeMirror").CodeMirror;
if (cm) {
- var lineElement = symbolEl.closest('.CodeMirror-line').parentElement;
+ var lineEl = symbolEl.closest('.CodeMirror-line').parentElement;
for (var view of cm.display.view) {
- if (view.node === lineElement) {
- return cm.getLineNumber(view.line);
+ if (view.node === lineEl) {
+ var row = cm.getLineNumber(view.line);
+ var parentEl = symbolEl.parentElement;
+ var text = '';
+ for (var i = 0; i < parentEl.childNodes.length; i++) {
+ var node = parentEl.childNodes[i];
+ if (node === symbolEl)
+ break;
+ text += getNodeText(node);
+ }
+ row++;
+ var columnStart = text.length + 1;
+ var symbolText = getNodeText(symbolEl);
+ return row + "." + columnStart + "-" + row + "." + (columnStart + symbolText.length);
}
}
}
- return -1;
+ return "";
}""";
}
@Override
- protected SymbolContext getSymbolContext(String symbolPosition, int beforeContextSize,
- int afterContextSize, int atStartContextSize) {
- var lineNo = Integer.parseInt(symbolPosition);
+ protected SymbolContext getSymbolContext(String symbolPosition, String symbolBegin, String symbolEnd,
+ String truncationMark, int atStartContextSize, int beforeContextSize, int afterContextSize) {
+ var range = new PlanarRange(symbolPosition);
var lines = context.getProject().getBlob(context.getBlobIdent(), true).getText().getLines();
- List<String> linesBefore = new ArrayList<>();
- List<String> linesAfter = new ArrayList<>();
- String symbolLine = lines.get(lineNo);
- for (int i = Math.max(0, lineNo - beforeContextSize); i < lineNo; i++) {
- linesBefore.add(lines.get(i));
- }
- for (int i = lineNo + 1; i <= Math.min(lineNo + afterContextSize, lines.size() - 1); i++) {
- linesAfter.add(lines.get(i));
- }
- List<String> linesAtStart = new ArrayList<>();
- for (int i = 0; i < Math.min(atStartContextSize, lines.size()); i++) {
- linesAtStart.add(lines.get(i));
- }
- return new SymbolContext(
- context.getBlobIdent().path,
- symbolLine,
- linesBefore,
- linesAfter,
- linesAtStart
- );
+
+ var symbolContext = range.getContext(lines, symbolBegin, symbolEnd, truncationMark,
+ atStartContextSize, beforeContextSize, afterContextSize);
+ return new SymbolContext(context.getBlobIdent().path, symbolContext);
}
});
@@ -964,17 +1014,13 @@ public class SourceViewPanel extends BlobViewPanel implements Positionable, Sear
}
return children;
}
-
- private GitService getGitService() {
- return OneDev.getInstance(GitService.class);
- }
-
+
private String getJsonOfBlameInfos(boolean blamed) {
String jsonOfBlameInfos;
if (blamed) {
List<BlameInfo> blameInfos = new ArrayList<>();
- for (BlameBlock blame: getGitService().blame(
+ for (BlameBlock blame: gitService.blame(
context.getProject(), context.getCommit().copy(), context.getBlobIdent().path, null)) {
BlameInfo blameInfo = new BlameInfo();
blameInfo.commitDate = DateUtils.formatDate(blame.getCommit().getCommitter().getWhen());
@@ -1022,11 +1068,7 @@ public class SourceViewPanel extends BlobViewPanel implements Positionable, Sear
explicit("action"), explicit("param1"), explicit("param2"),
explicit("param3"), explicit("param4"), explicit("param5"));
- PlanarRange markRange = BlobRenderer.getSourceRange(context.getPosition());
- if (markRange == null)
- markRange = (PlanarRange) commentContainer.getDefaultModelObject();
- else
- markRange = markRange.normalize(blob.getText().getLines());
+ PlanarRange markRange = getMarkRange();
var translations = new HashMap<String, String>();
translations.put("perma-link", _T("Permanent link of this selection"));
@@ -1038,6 +1080,10 @@ public class SourceViewPanel extends BlobViewPanel implements Positionable, Sear
translations.put("partially-covered-by-some-tests", _T("Partially covered by some tests"));
translations.put("unsaved-changes-prompt", _T("There are unsaved changes, discard and continue?"));
translations.put("show-comment", _T("Click to show comment of marked text"));
+ var page = (LayoutPage)getPage();
+ if (WicketUtils.isSubscriptionActive() && !page.getChatter().getEntitledAis().isEmpty())
+ translations.put("explain-selection", _T("Explain selected text with AI"));
+
translations.put("loading", _T("Loading..."));
for (var severity: CodeProblem.Severity.values())
translations.put(severity.name(), _T("severity:" + severity.name()));
@@ -1260,6 +1306,16 @@ public class SourceViewPanel extends BlobViewPanel implements Positionable, Sear
return fragment;
}
+
+ @Nullable
+ private PlanarRange getMarkRange() {
+ PlanarRange markRange = BlobRenderer.getSourceRange(context.getPosition());
+ if (markRange == null)
+ markRange = (PlanarRange) commentContainer.getDefaultModelObject();
+ else
+ markRange = markRange.normalize(context.getProject().getBlob(context.getBlobIdent(), true).getText().getLines());
+ return markRange;
+ }
@Override
public List<MenuItem> getMenuItems(FloatingPanel dropdown) {
@@ -1314,14 +1370,14 @@ public class SourceViewPanel extends BlobViewPanel implements Positionable, Sear
private void onSaveCommentReply(AjaxRequestTarget target, CodeCommentReply reply) {
reply.setCompareContext(getCompareContext());
if (reply.isNew())
- OneDev.getInstance(CodeCommentReplyService.class).create(reply);
+ codeCommentReplyService.create(reply);
else
- OneDev.getInstance(CodeCommentReplyService.class).update(reply);
+ codeCommentReplyService.update(reply);
}
private void onSaveCommentStatusChange(AjaxRequestTarget target, CodeCommentStatusChange change, String note) {
change.setCompareContext(getCompareContext());
- OneDev.getInstance(CodeCommentStatusChangeService.class).create(change, note);
+ codeCommentStatusChangeService.create(change, note);
}
private SuggestionSupport getSuggestionSupport(Mark mark) {
@@ -1385,5 +1441,39 @@ public class SourceViewPanel extends BlobViewPanel implements Positionable, Sear
};
}
-
+
+ @Override
+ public List<ChatTool> getChatTools() {
+ var tools = new ArrayList<ChatTool>();
+ tools.add(new ChatTool() {
+
+ @Override
+ public ToolSpecification getSpecification() {
+ return ToolSpecification.builder()
+ .name("getCurrentFileInformation")
+ .description("Get information of current file in json format, including file name and file content")
+ .build();
+ }
+
+ @Override
+ public String execute(JsonNode arguments) {
+ var lines = context.getProject().getBlob(context.getBlobIdent(), true).getText().getLines();
+ var map = Map.of(
+ "fileName", context.getBlobIdent().getName(),
+ "fileContent", Joiner.on('\n').join(lines)
+ );
+ return convertToJson(map);
+ }
+
+ });
+
+ var markRange = getMarkRange();
+ if (markRange != null) {
+ tools.add(new HighlightedTextTool(
+ context.getBlobIdent().getName(),
+ context.getProject().getBlob(context.getBlobIdent(), true).getText().getLines(),
+ markRange));
+ }
+ return tools;
+ }
}
diff --git a/server-core/src/main/java/io/onedev/server/web/page/project/blob/render/source/source-view.js b/server-core/src/main/java/io/onedev/server/web/page/project/blob/render/source/source-view.js
index 09a46d3da5..de18e07ed2 100644
--- a/server-core/src/main/java/io/onedev/server/web/page/project/blob/render/source/source-view.js
+++ b/server-core/src/main/java/io/onedev/server/web/page/project/blob/render/source/source-view.js
@@ -426,6 +426,18 @@ onedev.server.sourceView = {
$content.children("a.copy-marked").click(function() {
$(".selection-popover").remove();
});
+
+ var explainSelectionText = onedev.server.sourceView.translations["explain-selection"];
+ if (explainSelectionText) {
+ svg = `<svg class='icon mr-1'><use xlink:href='${onedev.server.icons}#ai2'/></svg>`;
+ $content.append(`<a class='explain-selection'>${svg} ${explainSelectionText}</a>`);
+ $content.children("a.explain-selection").click(function() {
+ $(".selection-popover").remove();
+ $(".source-view").data("callback")("explainSelection", selectionRange.fromRow, selectionRange.fromColumn,
+ selectionRange.toRow, selectionRange.toColumn);
+ });
+ }
+
if (loggedIn) {
let svg = `<svg class='icon mr-1'><use xlink:href='${onedev.server.icons}#comment'/></svg>`;
$content.append(`<a class='comment'>${svg} ${onedev.server.sourceView.translations["add-selection-comment"]}</a>`);
diff --git a/server-core/src/main/java/io/onedev/server/web/page/project/pullrequests/detail/activities/PullRequestActivitiesPage.html b/server-core/src/main/java/io/onedev/server/web/page/project/pullrequests/detail/activities/PullRequestActivitiesPage.html
index ce23db8ccd..464ebb8c88 100644
--- a/server-core/src/main/java/io/onedev/server/web/page/project/pullrequests/detail/activities/PullRequestActivitiesPage.html
+++ b/server-core/src/main/java/io/onedev/server/web/page/project/pullrequests/detail/activities/PullRequestActivitiesPage.html
@@ -22,7 +22,7 @@
</div>
</wicket:fragment>
<wicket:fragment wicket:id="optionsFrag">
- <a wicket:id="aiSummarize" t:data-tippy-content="Summarize comments with AI" class="btn btn-xs btn-outline-secondary btn-hover-primary btn-icon"><wicket:svg href="ai-summarize" class="icon"></wicket:svg></a>
+ <a wicket:id="aiSummarize" t:data-tippy-content="Summarize comments with AI" class="btn btn-xs btn-outline-secondary btn-hover-primary btn-icon"><wicket:svg href="ai2" class="icon"></wicket:svg></a>
<div class="btn-group">
<a wicket:id="showComments" t:data-tippy-content="Toggle comments" class="btn btn-xs text-muted btn-outline-secondary btn-active-secondary btn-icon"><wicket:svg href="comments" class="icon"></wicket:svg></a>
<a wicket:id="showCommits" t:data-tippy-content="Toggle commits" class="btn btn-xs text-muted btn-outline-secondary btn-active-secondary btn-icon"><wicket:svg href="commit" class="icon"></wicket:svg></a>
diff --git a/server-core/src/main/java/io/onedev/server/web/page/project/pullrequests/detail/activities/PullRequestActivitiesPage.java b/server-core/src/main/java/io/onedev/server/web/page/project/pullrequests/detail/activities/PullRequestActivitiesPage.java
index 53ccdb3b96..fbfd5e1cb4 100644
--- a/server-core/src/main/java/io/onedev/server/web/page/project/pullrequests/detail/activities/PullRequestActivitiesPage.java
+++ b/server-core/src/main/java/io/onedev/server/web/page/project/pullrequests/detail/activities/PullRequestActivitiesPage.java
@@ -417,7 +417,7 @@ public class PullRequestActivitiesPage extends PullRequestDetailPage {
@Override
public void onClick(AjaxRequestTarget target) {
var page = (LayoutPage)getPage();
- page.getChatter().show(target, "Summarize comments of current pull request. Display summary in " + getSession().getLocale().getDisplayLanguage());
+ page.getChatter().show(target, "Summarize comments of current pull request. Display in " + getSession().getLocale().getDisplayLanguage());
}
@Override
diff --git a/server-core/src/main/java/io/onedev/server/web/page/test/TestPage.java b/server-core/src/main/java/io/onedev/server/web/page/test/TestPage.java
index f1727e618c..e3a7878db1 100644
--- a/server-core/src/main/java/io/onedev/server/web/page/test/TestPage.java
+++ b/server-core/src/main/java/io/onedev/server/web/page/test/TestPage.java
@@ -22,6 +22,7 @@ public class TestPage extends BasePage {
@Override
public void onClick() {
+ System.out.println("test2");
}
});
diff --git a/server-core/src/main/java/io/onedev/server/web/translation/Translation_de.java b/server-core/src/main/java/io/onedev/server/web/translation/Translation_de.java
index 8531ed0dab..104f4e4e4f 100644
--- a/server-core/src/main/java/io/onedev/server/web/translation/Translation_de.java
+++ b/server-core/src/main/java/io/onedev/server/web/translation/Translation_de.java
@@ -793,6 +793,7 @@ public class Translation_de extends TranslationResourceBundle {
m.put("Confirm your action", "Aktion bestätigen");
m.put("Connect New Agent", "Neuen Agent verbinden");
m.put("Connect with your SSO account", "Mit Ihrem SSO-Konto verbinden");
+ m.put("Connection lost or session expired, reload to recover", "Verbindung verloren oder Sitzung abgelaufen, neu laden, um wiederherzustellen");
m.put("Contact Email", "Kontakt-E-Mail");
m.put("Contact Name", "Kontaktname");
m.put("Container Image", "Container-Image");
@@ -1269,6 +1270,7 @@ public class Translation_de extends TranslationResourceBundle {
m.put("Expiration Date:", "Ablaufdatum:");
m.put("Expire Date", "Ablaufdatum");
m.put("Expired", "Abgelaufen");
+ m.put("Explain selected text with AI", "Erklären Sie den ausgewählten Text mit KI");
m.put("Explicit SSL (StartTLS)", "Explizites SSL (StartTLS)");
m.put("Export", "Exportieren");
m.put("Export All Queried Issues To...", "Alle abgefragten Probleme exportieren nach...");
@@ -4684,7 +4686,6 @@ public class Translation_de extends TranslationResourceBundle {
m.put("{javax.validation.constraints.NotEmpty.message}", "{javax.validation.constraints.NotEmpty.message}");
m.put("{javax.validation.constraints.NotNull.message}", "{javax.validation.constraints.NotNull.message}");
m.put("{javax.validation.constraints.Size.message}", "{javax.validation.constraints.Size.message}");
- m.put("Connection lost or session expired, reload to recover", "Verbindung verloren oder Sitzung abgelaufen, neu laden, um wiederherzustellen");
}
@Override
diff --git a/server-core/src/main/java/io/onedev/server/web/translation/Translation_es.java b/server-core/src/main/java/io/onedev/server/web/translation/Translation_es.java
index b968d892e1..0d84ef1d8c 100644
--- a/server-core/src/main/java/io/onedev/server/web/translation/Translation_es.java
+++ b/server-core/src/main/java/io/onedev/server/web/translation/Translation_es.java
@@ -793,6 +793,7 @@ public class Translation_es extends TranslationResourceBundle {
m.put("Confirm your action", "Confirma tu acción");
m.put("Connect New Agent", "Conectar Nuevo Agente");
m.put("Connect with your SSO account", "Conéctate con tu cuenta SSO");
+ m.put("Connection lost or session expired, reload to recover", "Conexión perdida o sesión expirada, recargar para recuperar");
m.put("Contact Email", "Correo Electrónico de Contacto");
m.put("Contact Name", "Nombre de Contacto");
m.put("Container Image", "Imagen del Contenedor");
@@ -1269,6 +1270,7 @@ public class Translation_es extends TranslationResourceBundle {
m.put("Expiration Date:", "Fecha de Expiración:");
m.put("Expire Date", "Fecha de Expiración");
m.put("Expired", "Expirado");
+ m.put("Explain selected text with AI", "Explicar el texto seleccionado con IA");
m.put("Explicit SSL (StartTLS)", "SSL Explícito (StartTLS)");
m.put("Export", "Exportar");
m.put("Export All Queried Issues To...", "Exportar Todos los Problemas Consultados A...");
@@ -4684,7 +4686,6 @@ public class Translation_es extends TranslationResourceBundle {
m.put("{javax.validation.constraints.NotEmpty.message}", "{javax.validation.constraints.NotEmpty.message}");
m.put("{javax.validation.constraints.NotNull.message}", "{javax.validation.constraints.NotNull.message}");
m.put("{javax.validation.constraints.Size.message}", "{javax.validation.constraints.Size.message}");
- m.put("Connection lost or session expired, reload to recover", "Conexión perdida o sesión expirada, recargar para recuperar");
}
@Override
diff --git a/server-core/src/main/java/io/onedev/server/web/translation/Translation_fr.java b/server-core/src/main/java/io/onedev/server/web/translation/Translation_fr.java
index 5d5bf38623..229f5e8b5c 100644
--- a/server-core/src/main/java/io/onedev/server/web/translation/Translation_fr.java
+++ b/server-core/src/main/java/io/onedev/server/web/translation/Translation_fr.java
@@ -793,6 +793,7 @@ public class Translation_fr extends TranslationResourceBundle {
m.put("Confirm your action", "Confirmez votre action");
m.put("Connect New Agent", "Connecter un nouvel agent");
m.put("Connect with your SSO account", "Connectez-vous avec votre compte SSO");
+ m.put("Connection lost or session expired, reload to recover", "Connexion perdue ou session expirée, rechargez pour récupérer");
m.put("Contact Email", "Email de contact");
m.put("Contact Name", "Nom de contact");
m.put("Container Image", "Image du conteneur");
@@ -1269,6 +1270,7 @@ public class Translation_fr extends TranslationResourceBundle {
m.put("Expiration Date:", "Date d'expiration :");
m.put("Expire Date", "Date d'expiration");
m.put("Expired", "Expiré");
+ m.put("Explain selected text with AI", "Expliquer le texte sélectionné avec l'IA");
m.put("Explicit SSL (StartTLS)", "SSL explicite (StartTLS)");
m.put("Export", "Exporter");
m.put("Export All Queried Issues To...", "Exporter toutes les questions interrogées vers...");
@@ -4684,7 +4686,6 @@ public class Translation_fr extends TranslationResourceBundle {
m.put("{javax.validation.constraints.NotEmpty.message}", "{javax.validation.constraints.NotEmpty.message}");
m.put("{javax.validation.constraints.NotNull.message}", "{javax.validation.constraints.NotNull.message}");
m.put("{javax.validation.constraints.Size.message}", "{javax.validation.constraints.Size.message}");
- m.put("Connection lost or session expired, reload to recover", "Connexion perdue ou session expirée, rechargez pour récupérer");
}
@Override
diff --git a/server-core/src/main/java/io/onedev/server/web/translation/Translation_it.java b/server-core/src/main/java/io/onedev/server/web/translation/Translation_it.java
index 0b07b4f994..96232554b3 100644
--- a/server-core/src/main/java/io/onedev/server/web/translation/Translation_it.java
+++ b/server-core/src/main/java/io/onedev/server/web/translation/Translation_it.java
@@ -793,6 +793,7 @@ public class Translation_it extends TranslationResourceBundle {
m.put("Confirm your action", "Conferma la tua azione");
m.put("Connect New Agent", "Connetti Nuovo Agente");
m.put("Connect with your SSO account", "Connettiti con il tuo account SSO");
+ m.put("Connection lost or session expired, reload to recover", "Connessione persa o sessione scaduta, ricarica per recuperare");
m.put("Contact Email", "Email di Contatto");
m.put("Contact Name", "Nome di Contatto");
m.put("Container Image", "Immagine del Container");
@@ -1269,6 +1270,7 @@ public class Translation_it extends TranslationResourceBundle {
m.put("Expiration Date:", "Data di Scadenza:");
m.put("Expire Date", "Data di Scadenza");
m.put("Expired", "Scaduto");
+ m.put("Explain selected text with AI", "Spiega il testo selezionato con l'IA");
m.put("Explicit SSL (StartTLS)", "SSL Esplicito (StartTLS)");
m.put("Export", "Esporta");
m.put("Export All Queried Issues To...", "Esporta Tutti i Problemi Interrogati In...");
@@ -4684,7 +4686,6 @@ public class Translation_it extends TranslationResourceBundle {
m.put("{javax.validation.constraints.NotEmpty.message}", "{javax.validation.constraints.NotEmpty.message}");
m.put("{javax.validation.constraints.NotNull.message}", "{javax.validation.constraints.NotNull.message}");
m.put("{javax.validation.constraints.Size.message}", "{javax.validation.constraints.Size.message}");
- m.put("Connection lost or session expired, reload to recover", "Connessione persa o sessione scaduta, ricarica per recuperare");
}
@Override
diff --git a/server-core/src/main/java/io/onedev/server/web/translation/Translation_ja.java b/server-core/src/main/java/io/onedev/server/web/translation/Translation_ja.java
index 6378343f57..5ef94aefc6 100644
--- a/server-core/src/main/java/io/onedev/server/web/translation/Translation_ja.java
+++ b/server-core/src/main/java/io/onedev/server/web/translation/Translation_ja.java
@@ -793,6 +793,7 @@ public class Translation_ja extends TranslationResourceBundle {
m.put("Confirm your action", "アクションを確認");
m.put("Connect New Agent", "新しいエージェントを接続");
m.put("Connect with your SSO account", "SSOアカウントで接続");
+ m.put("Connection lost or session expired, reload to recover", "接続が失われたかセッションが期限切れです。復元するにはリロードしてください。");
m.put("Contact Email", "連絡先メール");
m.put("Contact Name", "連絡先名");
m.put("Container Image", "コンテナイメージ");
@@ -1269,6 +1270,7 @@ public class Translation_ja extends TranslationResourceBundle {
m.put("Expiration Date:", "有効期限:");
m.put("Expire Date", "有効期限");
m.put("Expired", "期限切れ");
+ m.put("Explain selected text with AI", "選択したテキストをAIで説明する");
m.put("Explicit SSL (StartTLS)", "明示的SSL (StartTLS)");
m.put("Export", "エクスポート");
m.put("Export All Queried Issues To...", "クエリされたすべての問題をエクスポート...");
@@ -4684,7 +4686,6 @@ public class Translation_ja extends TranslationResourceBundle {
m.put("{javax.validation.constraints.NotEmpty.message}", "{javax.validation.constraints.NotEmpty.message}");
m.put("{javax.validation.constraints.NotNull.message}", "{javax.validation.constraints.NotNull.message}");
m.put("{javax.validation.constraints.Size.message}", "{javax.validation.constraints.Size.message}");
- m.put("Connection lost or session expired, reload to recover", "接続が失われたかセッションが期限切れです。復元するにはリロードしてください。");
}
@Override
diff --git a/server-core/src/main/java/io/onedev/server/web/translation/Translation_ko.java b/server-core/src/main/java/io/onedev/server/web/translation/Translation_ko.java
index 201a5e0f43..92c8256ae8 100644
--- a/server-core/src/main/java/io/onedev/server/web/translation/Translation_ko.java
+++ b/server-core/src/main/java/io/onedev/server/web/translation/Translation_ko.java
@@ -793,6 +793,7 @@ public class Translation_ko extends TranslationResourceBundle {
m.put("Confirm your action", "작업을 확인하세요");
m.put("Connect New Agent", "새 에이전트 연결");
m.put("Connect with your SSO account", "SSO 계정으로 연결");
+ m.put("Connection lost or session expired, reload to recover", "연결이 끊어졌거나 세션이 만료되었습니다. 복구하려면 새로 고침하세요.");
m.put("Contact Email", "연락처 이메일");
m.put("Contact Name", "연락처 이름");
m.put("Container Image", "컨테이너 이미지");
@@ -1269,6 +1270,7 @@ public class Translation_ko extends TranslationResourceBundle {
m.put("Expiration Date:", "만료 날짜:");
m.put("Expire Date", "만료 날짜");
m.put("Expired", "만료됨");
+ m.put("Explain selected text with AI", "선택한 텍스트를 AI로 설명하기");
m.put("Explicit SSL (StartTLS)", "명시적 SSL (StartTLS)");
m.put("Export", "내보내기");
m.put("Export All Queried Issues To...", "모든 조회된 이슈를 내보내기...");
@@ -4684,7 +4686,6 @@ public class Translation_ko extends TranslationResourceBundle {
m.put("{javax.validation.constraints.NotEmpty.message}", "{javax.validation.constraints.NotEmpty.message}");
m.put("{javax.validation.constraints.NotNull.message}", "{javax.validation.constraints.NotNull.message}");
m.put("{javax.validation.constraints.Size.message}", "{javax.validation.constraints.Size.message}");
- m.put("Connection lost or session expired, reload to recover", "연결이 끊어졌거나 세션이 만료되었습니다. 복구하려면 새로 고침하세요.");
}
@Override
diff --git a/server-core/src/main/java/io/onedev/server/web/translation/Translation_pt.java b/server-core/src/main/java/io/onedev/server/web/translation/Translation_pt.java
index 53bf84aaa4..b39914a876 100644
--- a/server-core/src/main/java/io/onedev/server/web/translation/Translation_pt.java
+++ b/server-core/src/main/java/io/onedev/server/web/translation/Translation_pt.java
@@ -793,6 +793,7 @@ public class Translation_pt extends TranslationResourceBundle {
m.put("Confirm your action", "Confirme sua ação");
m.put("Connect New Agent", "Conectar Novo Agente");
m.put("Connect with your SSO account", "Conecte-se com sua conta SSO");
+ m.put("Connection lost or session expired, reload to recover", "Conexão perdida ou sessão expirada, recarregue para recuperar");
m.put("Contact Email", "Email de Contato");
m.put("Contact Name", "Nome de Contato");
m.put("Container Image", "Imagem do Container");
@@ -1269,6 +1270,7 @@ public class Translation_pt extends TranslationResourceBundle {
m.put("Expiration Date:", "Data de Expiração:");
m.put("Expire Date", "Data de Expiração");
m.put("Expired", "Expirado");
+ m.put("Explain selected text with AI", "Explique o texto selecionado com IA");
m.put("Explicit SSL (StartTLS)", "SSL Explícito (StartTLS)");
m.put("Export", "Exportar");
m.put("Export All Queried Issues To...", "Exportar Todas as Questões Consultadas Para...");
@@ -4684,7 +4686,6 @@ public class Translation_pt extends TranslationResourceBundle {
m.put("{javax.validation.constraints.NotEmpty.message}", "{javax.validation.constraints.NotEmpty.message}");
m.put("{javax.validation.constraints.NotNull.message}", "{javax.validation.constraints.NotNull.message}");
m.put("{javax.validation.constraints.Size.message}", "{javax.validation.constraints.Size.message}");
- m.put("Connection lost or session expired, reload to recover", "Conexão perdida ou sessão expirada, recarregue para recuperar");
}
@Override
diff --git a/server-core/src/main/java/io/onedev/server/web/translation/Translation_zh.java b/server-core/src/main/java/io/onedev/server/web/translation/Translation_zh.java
index 2a5a1f1495..16bf92b51b 100644
--- a/server-core/src/main/java/io/onedev/server/web/translation/Translation_zh.java
+++ b/server-core/src/main/java/io/onedev/server/web/translation/Translation_zh.java
@@ -812,6 +812,7 @@ public class Translation_zh extends TranslationResourceBundle {
m.put("Confirm your action", "确认你的操作");
m.put("Connect New Agent", "连接新代理");
m.put("Connect with your SSO account", "使用您的 SSO 账户连接");
+ m.put("Connection lost or session expired, reload to recover", "连接丢失或会话过期,重新加载以恢复");
m.put("Contact Email", "联系邮箱");
m.put("Contact Name", "联系人");
m.put("Container Image", "容器镜像");
@@ -1288,6 +1289,7 @@ public class Translation_zh extends TranslationResourceBundle {
m.put("Expiration Date:", "到期日期:");
m.put("Expire Date", "过期日期");
m.put("Expired", "已过期");
+ m.put("Explain selected text with AI", "用 AI 解释选定文本");
m.put("Explicit SSL (StartTLS)", "显式 SSL (StartTLS)");
m.put("Export", "导出");
m.put("Export All Queried Issues To...", "导出所有查询的工单到...");
@@ -4703,7 +4705,6 @@ public class Translation_zh extends TranslationResourceBundle {
m.put("{javax.validation.constraints.NotEmpty.message}", "不能为空");
m.put("{javax.validation.constraints.NotNull.message}", "不能为空");
m.put("{javax.validation.constraints.Size.message}", "至少需要指定一个值");
- m.put("Connection lost or session expired, reload to recover", "连接丢失或会话过期,重新加载以恢复");
}
@Override
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/AbstractRevQueue.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/AbstractRevQueue.java
index e0c7bdd396..73ae62a23f 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/AbstractRevQueue.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/AbstractRevQueue.java
@@ -66,7 +66,7 @@ abstract class AbstractRevQueue extends Generator {
* flag that controls admission to the queue.
*/
public final void addParents(RevCommit c, RevFlag queueControl) {
- final RevCommit[] pList = c.parents;
+ final RevCommit[] pList = c.getParents();
if (pList == null) {
return;
}
@@ -79,8 +79,6 @@ abstract class AbstractRevQueue extends Generator {
}
/**
- * {@inheritDoc}
- * <p>
* Remove the first commit from the queue.
*/
@Override
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/BitmapWalker.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/BitmapWalker.java
index 1576145229..92b38f0388 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/BitmapWalker.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/BitmapWalker.java
@@ -50,12 +50,15 @@ public final class BitmapWalker {
/**
* Create a BitmapWalker.
*
- * @param walker walker to use when traversing the object graph.
- * @param bitmapIndex index to obtain bitmaps from.
- * @param pm progress monitor to report progress on.
+ * @param walker
+ * walker to use when traversing the object graph.
+ * @param bitmapIndex
+ * index to obtain bitmaps from.
+ * @param pm
+ * progress monitor to report progress on.
*/
- public BitmapWalker(
- ObjectWalk walker, BitmapIndex bitmapIndex, ProgressMonitor pm) {
+ public BitmapWalker(ObjectWalk walker, BitmapIndex bitmapIndex,
+ ProgressMonitor pm) {
this.walker = walker;
this.bitmapIndex = bitmapIndex;
this.pm = (pm == null) ? NullProgressMonitor.INSTANCE : pm;
@@ -177,8 +180,9 @@ public final class BitmapWalker {
for (ObjectId obj : start) {
Bitmap bitmap = bitmapIndex.getBitmap(obj);
- if (bitmap != null)
+ if (bitmap != null) {
bitmapResult.or(bitmap);
+ }
}
boolean marked = false;
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/BlockRevQueue.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/BlockRevQueue.java
index cdd8073d6e..e855d8f700 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/BlockRevQueue.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/BlockRevQueue.java
@@ -45,8 +45,6 @@ abstract class BlockRevQueue extends AbstractRevQueue {
}
/**
- * {@inheritDoc}
- * <p>
* Reconfigure this queue to share the same free list as another.
* <p>
* Multiple revision queues can be connected to the same free list, making
@@ -56,6 +54,11 @@ abstract class BlockRevQueue extends AbstractRevQueue {
* <p>
* Free lists are not thread-safe. Applications must ensure that all queues
* sharing the same free list are doing so from only a single thread.
+ *
+ * @param q
+ * another FIFO queue that wants to share our queue's free list.
+ *
+ * @see Generator#shareFreeList
*/
@Override
public void shareFreeList(BlockRevQueue q) {
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/BoundaryGenerator.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/BoundaryGenerator.java
index 8b78d062b5..bdf63ff10b 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/BoundaryGenerator.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/BoundaryGenerator.java
@@ -76,11 +76,12 @@ class BoundaryGenerator extends Generator {
IncorrectObjectTypeException, IOException {
RevCommit c = source.next();
if (c != null) {
- for (int i = 0; i < c.parents.length; i++) {
+ int n = c.getParentCount();
+ for (int i = 0; i < n; i++) {
if (firstParent && i > 0) {
break;
}
- RevCommit p = c.parents[i];
+ RevCommit p = c.getParent(i);
if ((p.flags & UNINTERESTING) != 0) {
held.add(p);
}
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/DateRevPriorityQueue.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/DateRevPriorityQueue.java
new file mode 100644
index 0000000000..233dd64a3c
--- /dev/null
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/DateRevPriorityQueue.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2023, GerritForge Ltd
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+package org.eclipse.jgit.revwalk;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.eclipse.jgit.annotations.Nullable;
+import org.eclipse.jgit.errors.IncorrectObjectTypeException;
+import org.eclipse.jgit.errors.MissingObjectException;
+import org.eclipse.jgit.internal.JGitText;
+
+import java.io.IOException;
+import java.util.Comparator;
+import java.util.PriorityQueue;
+
+/**
+ * A queue of commits sorted by commit time order using a Java PriorityQueue.
+ * For the commits with the same commit time insertion order will be preserved.
+ */
+class DateRevPriorityQueue extends DateRevQueue {
+ private PriorityQueue<RevCommitEntry> queue;
+
+ private final AtomicInteger sequence = new AtomicInteger(1);
+
+ /**
+ * Create an empty queue of commits sorted by commit time order.
+ */
+ public DateRevPriorityQueue() {
+ this(false);
+ }
+
+ /**
+ * Create an empty queue of commits sorted by commit time order.
+ *
+ * @param firstParent
+ * treat first element as a parent
+ */
+ DateRevPriorityQueue(boolean firstParent) {
+ super(firstParent);
+ initPriorityQueue();
+ }
+
+ private void initPriorityQueue() {
+ sequence.set(1);
+ queue = new PriorityQueue<>(Comparator.comparingInt(
+ (RevCommitEntry ent) -> ent.getEntry().getCommitTime())
+ .reversed()
+ .thenComparingInt(RevCommitEntry::getInsertSequenceNumber));
+ }
+
+ DateRevPriorityQueue(Generator s) throws MissingObjectException,
+ IncorrectObjectTypeException, IOException {
+ this(s.firstParent);
+ for (;;) {
+ final RevCommit c = s.next();
+ if (c == null) {
+ break;
+ }
+ add(c);
+ }
+ }
+
+ @Override
+ public void add(RevCommit c) {
+ // PriorityQueue does not accept null values. To keep the same behaviour
+ // do the same check and throw the same exception before creating entry
+ if (c == null) {
+ throw new NullPointerException(JGitText.get().nullRevCommit);
+ }
+ queue.add(new RevCommitEntry(sequence.getAndIncrement(), c));
+ }
+
+ @Override
+ public RevCommit next() {
+ RevCommitEntry entry = queue.poll();
+ return entry == null ? null : entry.getEntry();
+ }
+
+ /**
+ * Peek at the next commit, without removing it.
+ *
+ * @return the next available commit; null if there are no commits left.
+ */
+ @Override
+ public @Nullable RevCommit peek() {
+ RevCommitEntry entry = queue.peek();
+ return entry == null ? null : entry.getEntry();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void clear() {
+ sequence.set(1);
+ queue.clear();
+ }
+
+ @Override
+ boolean everbodyHasFlag(int f) {
+ return queue.stream().map(RevCommitEntry::getEntry)
+ .noneMatch(c -> (c.flags & f) == 0);
+ }
+
+ @Override
+ boolean anybodyHasFlag(int f) {
+ return queue.stream().map(RevCommitEntry::getEntry)
+ .anyMatch(c -> (c.flags & f) != 0);
+ }
+
+ @Override
+ int outputType() {
+ return outputType | SORT_COMMIT_TIME_DESC;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder s = new StringBuilder();
+ for (RevCommitEntry e : queue) {
+ describe(s, e.getEntry());
+ }
+ return s.toString();
+ }
+
+ private static class RevCommitEntry {
+ private final int insertSequenceNumber;
+
+ private final RevCommit entry;
+
+ public RevCommitEntry(int insertSequenceNumber, RevCommit entry) {
+ this.insertSequenceNumber = insertSequenceNumber;
+ this.entry = entry;
+ }
+
+ public int getInsertSequenceNumber() {
+ return insertSequenceNumber;
+ }
+
+ public RevCommit getEntry() {
+ return entry;
+ }
+ }
+}
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/DateRevQueue.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/DateRevQueue.java
index 0cabf07057..905dcb62ad 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/DateRevQueue.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/DateRevQueue.java
@@ -8,11 +8,11 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-
package org.eclipse.jgit.revwalk;
import java.io.IOException;
+import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
@@ -36,11 +36,17 @@ public class DateRevQueue extends AbstractRevQueue {
private int last = -1;
- /** Create an empty date queue. */
+ /** Create an empty DateRevQueue. */
public DateRevQueue() {
super(false);
}
+ /**
+ * Create an empty DateRevQueue.
+ *
+ * @param firstParent
+ * treat first element as a parent
+ */
DateRevQueue(boolean firstParent) {
super(firstParent);
}
@@ -56,7 +62,6 @@ public class DateRevQueue extends AbstractRevQueue {
}
}
- /** {@inheritDoc} */
@Override
public void add(RevCommit c) {
sinceLastIndex++;
@@ -102,7 +107,6 @@ public class DateRevQueue extends AbstractRevQueue {
}
}
- /** {@inheritDoc} */
@Override
public RevCommit next() {
final Entry q = head;
@@ -135,11 +139,10 @@ public class DateRevQueue extends AbstractRevQueue {
*
* @return the next available commit; null if there are no commits left.
*/
- public RevCommit peek() {
+ public @Nullable RevCommit peek() {
return head != null ? head.commit : null;
}
- /** {@inheritDoc} */
@Override
public void clear() {
head = null;
@@ -173,7 +176,6 @@ public class DateRevQueue extends AbstractRevQueue {
return outputType | SORT_COMMIT_TIME_DESC;
}
- /** {@inheritDoc} */
@Override
public String toString() {
final StringBuilder s = new StringBuilder();
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/DepthGenerator.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/DepthGenerator.java
index 7238e17fca..c4acab436d 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/DepthGenerator.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/DepthGenerator.java
@@ -55,10 +55,15 @@ class DepthGenerator extends Generator {
/**
* @param w
- * @param s Parent generator
+ * walk used for depth filtering
+ * @param s
+ * Parent generator
* @throws MissingObjectException
+ * if an object is missing
* @throws IncorrectObjectTypeException
+ * if an object has an unexpected type
* @throws IOException
+ * if an IO error occurred
*/
DepthGenerator(DepthWalk w, Generator s) throws MissingObjectException,
IncorrectObjectTypeException, IOException {
@@ -97,6 +102,11 @@ class DepthGenerator extends Generator {
pending.unpop(c);
}
+ // Mark DEEPEN_NOT on all deepen-not commits and their ancestors.
+ // inefficient in that any "deepen-not <ref>" in the request
+ // results in all commits reachable from that ref being parsed
+ // and marked, even if the commit topology is such that it is
+ // not necessary.
for (ObjectId oid : w.getDeepenNots()) {
RevCommit c;
try {
@@ -158,11 +168,12 @@ class DepthGenerator extends Generator {
int newDepth = c.depth + 1;
- for (int i = 0; i < c.parents.length; i++) {
+ int n = c.getParentCount();
+ for (int i = 0; i < n; i++) {
if (firstParent && i > 0) {
break;
}
- RevCommit p = c.parents[i];
+ RevCommit p = c.getParent(i);
DepthWalk.Commit dp = (DepthWalk.Commit) p;
// If no depth has been assigned to this commit, assign
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/DepthWalk.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/DepthWalk.java
index 5277563ac4..a7ffd34233 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/DepthWalk.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/DepthWalk.java
@@ -35,6 +35,8 @@ public interface DepthWalk {
int getDepth();
/**
+ * Get deepen-since value
+ *
* @return the deepen-since value; if not 0, this walk only returns commits
* whose commit time is at or after this limit
* @since 5.2
@@ -44,6 +46,8 @@ public interface DepthWalk {
}
/**
+ * Get deepen-not values
+ *
* @return the objects specified by the client using --shallow-exclude
* @since 5.2
*/
@@ -51,7 +55,11 @@ public interface DepthWalk {
return Collections.emptyList();
}
- /** @return flag marking commits that should become unshallow. */
+ /**
+ * Get unshallow flag
+ *
+ * @return flag marking commits that should become unshallow.
+ */
/**
* Get flag marking commits that should become unshallow.
*
@@ -67,7 +75,10 @@ public interface DepthWalk {
RevFlag getReinterestingFlag();
/**
- * @return flag marking commits that are to be excluded because of --shallow-exclude
+ * Get deepen-not flag
+ *
+ * @return flag marking commits that are to be excluded because of
+ * --shallow-exclude
* @since 5.2
*/
RevFlag getDeepenNotFlag();
@@ -85,12 +96,18 @@ public interface DepthWalk {
*/
boolean makesChildBoundary;
- /** @return depth of this commit, as found by the shortest path. */
+ /**
+ * Get depth
+ *
+ * @return depth of this commit, as found by the shortest path.
+ */
public int getDepth() {
return depth;
}
/**
+ * Whether at least one commit was excluded due to shallow fetch
+ *
* @return true if at least one of this commit's parents was excluded
* due to a shallow fetch setting, false otherwise
* @since 5.2
@@ -126,8 +143,12 @@ public interface DepthWalk {
private final RevFlag DEEPEN_NOT;
/**
- * @param repo Repository to walk
- * @param depth Maximum depth to return
+ * Create RevWalk
+ *
+ * @param repo
+ * Repository to walk
+ * @param depth
+ * Maximum depth to return
*/
public RevWalk(Repository repo, int depth) {
super(repo);
@@ -140,8 +161,12 @@ public interface DepthWalk {
}
/**
- * @param or ObjectReader to use
- * @param depth Maximum depth to return
+ * Create RevWalk
+ *
+ * @param or
+ * ObjectReader to use
+ * @param depth
+ * Maximum depth to return
*/
public RevWalk(ObjectReader or, int depth) {
super(or);
@@ -159,8 +184,11 @@ public interface DepthWalk {
* @param c
* Commit to mark
* @throws IOException
+ * if an IO error occurred
* @throws IncorrectObjectTypeException
+ * if object has an unexpected type
* @throws MissingObjectException
+ * if object is missing
*/
public void markRoot(RevCommit c) throws MissingObjectException,
IncorrectObjectTypeException, IOException {
@@ -228,6 +256,8 @@ public interface DepthWalk {
}
/**
+ * Convert to ObjectWalk with same objects
+ *
* @since 4.5
*/
@Override
@@ -256,8 +286,12 @@ public interface DepthWalk {
private final RevFlag DEEPEN_NOT;
/**
- * @param repo Repository to walk
- * @param depth Maximum depth to return
+ * Create ObjectWalk
+ *
+ * @param repo
+ * Repository to walk
+ * @param depth
+ * Maximum depth to return
*/
public ObjectWalk(Repository repo, int depth) {
super(repo);
@@ -270,8 +304,12 @@ public interface DepthWalk {
}
/**
- * @param or Object Reader
- * @param depth Maximum depth to return
+ * Create ObjectWalk
+ *
+ * @param or
+ * Object Reader
+ * @param depth
+ * Maximum depth to return
*/
public ObjectWalk(ObjectReader or, int depth) {
super(or);
@@ -289,8 +327,11 @@ public interface DepthWalk {
* @param o
* Commit to mark
* @throws IOException
+ * if an IO error occurred
* @throws IncorrectObjectTypeException
+ * if object has an unexpected type
* @throws MissingObjectException
+ * if object is missing
*/
public void markRoot(RevObject o) throws MissingObjectException,
IncorrectObjectTypeException, IOException {
@@ -313,8 +354,11 @@ public interface DepthWalk {
* @param c
* Commit to mark
* @throws MissingObjectException
+ * if object is missing
* @throws IncorrectObjectTypeException
+ * if object has an unexpected type
* @throws IOException
+ * if an IO error occurred
*/
public void markUnshallow(RevObject c) throws MissingObjectException,
IncorrectObjectTypeException, IOException {
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/FIFORevQueue.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/FIFORevQueue.java
index 0f8eddd6d4..996745c158 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/FIFORevQueue.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/FIFORevQueue.java
@@ -37,7 +37,6 @@ public class FIFORevQueue extends BlockRevQueue {
super(s);
}
- /** {@inheritDoc} */
@Override
public void add(RevCommit c) {
Block b = tail;
@@ -82,7 +81,6 @@ public class FIFORevQueue extends BlockRevQueue {
head = b;
}
- /** {@inheritDoc} */
@Override
public RevCommit next() {
final Block b = head;
@@ -99,7 +97,6 @@ public class FIFORevQueue extends BlockRevQueue {
return c;
}
- /** {@inheritDoc} */
@Override
public void clear() {
head = null;
@@ -135,7 +132,6 @@ public class FIFORevQueue extends BlockRevQueue {
}
}
- /** {@inheritDoc} */
@Override
public String toString() {
final StringBuilder s = new StringBuilder();
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/FollowFilter.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/FollowFilter.java
index d179a9441f..f946e32a84 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/FollowFilter.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/FollowFilter.java
@@ -11,6 +11,8 @@
package org.eclipse.jgit.revwalk;
import java.io.IOException;
+import java.util.Optional;
+import java.util.Set;
import org.eclipse.jgit.diff.DiffConfig;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
@@ -77,7 +79,6 @@ public class FollowFilter extends TreeFilter {
return path.getPath();
}
- /** {@inheritDoc} */
@Override
public boolean include(TreeWalk walker)
throws MissingObjectException, IncorrectObjectTypeException,
@@ -85,19 +86,22 @@ public class FollowFilter extends TreeFilter {
return path.include(walker) && ANY_DIFF.include(walker);
}
- /** {@inheritDoc} */
@Override
public boolean shouldBeRecursive() {
return path.shouldBeRecursive() || ANY_DIFF.shouldBeRecursive();
}
+ @Override
+ public Optional<Set<byte[]>> getPathsBestEffort() {
+ return path.getPathsBestEffort();
+ }
+
/** {@inheritDoc} */
@Override
public TreeFilter clone() {
return new FollowFilter(path.clone(), cfg);
}
- /** {@inheritDoc} */
@Override
public String toString() {
return "(FOLLOW(" + path.toString() + ")" //
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/FooterKey.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/FooterKey.java
index ed99282c5a..d6733ea34b 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/FooterKey.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/FooterKey.java
@@ -51,7 +51,6 @@ public final class FooterKey {
return name;
}
- /** {@inheritDoc} */
@Override
public String toString() {
return "FooterKey[" + name + "]";
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/FooterLine.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/FooterLine.java
index 3d128a6bd3..fa7fb316c9 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/FooterLine.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/FooterLine.java
@@ -11,6 +11,9 @@
package org.eclipse.jgit.revwalk;
import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import org.eclipse.jgit.util.RawParseUtils;
@@ -46,6 +49,137 @@ public final class FooterLine {
valEnd = ve;
}
+ /**
+ * Extract the footer lines from the given message.
+ *
+ * @param str
+ * the message to extract footers from.
+ * @return ordered list of footer lines; empty list if no footers found.
+ * @see RevCommit#getFooterLines()
+ * @since 6.7
+ */
+ public static List<FooterLine> fromMessage(
+ String str) {
+ return fromMessage(str.getBytes());
+ }
+
+ /**
+ * Extract the footer lines from the given message.
+ *
+ * @param raw
+ * the raw message to extract footers from.
+ * @return ordered list of footer lines; empty list if no footers found.
+ * @see RevCommit#getFooterLines()
+ * @since 6.7
+ */
+ public static List<FooterLine> fromMessage(
+ byte[] raw) {
+ // Find the end of the last paragraph.
+ int parEnd = raw.length;
+ for (; parEnd > 0 && (raw[parEnd - 1] == '\n'
+ || raw[parEnd - 1] == ' '); --parEnd) {
+ // empty
+ }
+
+ // The first non-header line is never a footer.
+ int msgB = RawParseUtils.nextLfSkippingSplitLines(raw,
+ RawParseUtils.hasAnyKnownHeaders(raw)
+ ? RawParseUtils.commitMessage(raw, 0)
+ : 0);
+ ArrayList<FooterLine> r = new ArrayList<>(4);
+ Charset enc = RawParseUtils.guessEncoding(raw);
+
+ // Search for the beginning of last paragraph
+ int parStart = parEnd;
+ for (; parStart > msgB; --parStart) {
+ if (parStart < 2) {
+ // Too close to beginning: this is not a raw message
+ parStart = 0;
+ break;
+ }
+ if (raw[parStart - 1] == '\n' && raw[parStart - 2] == '\n') {
+ break;
+ }
+ }
+
+ for (int ptr = parStart; ptr < parEnd;) {
+ int keyStart = ptr;
+ int keyEnd = RawParseUtils.endOfFooterLineKey(raw, ptr);
+ if (keyEnd < 0) {
+ // Not a well-formed footer line, skip it.
+ ptr = RawParseUtils.nextLF(raw, ptr);
+ continue;
+ }
+
+ // Skip over the ': *' at the end of the key before the value.
+ int valStart;
+ int valEnd;
+ for (valStart = keyEnd + 1; valStart < raw.length
+ && raw[valStart] == ' '; ++valStart) {
+ // empty
+ }
+
+ for(ptr = valStart;;) {
+ ptr = RawParseUtils.nextLF(raw, ptr);
+ // Next line starts with whitespace for a multiline footer.
+ if (ptr == raw.length || raw[ptr] != ' ') {
+ valEnd = raw[ptr - 1] == '\n' ? ptr - 1 : ptr;
+ break;
+ }
+ }
+ if (keyStart == msgB) {
+ // Fist line cannot be a footer
+ continue;
+ }
+ r.add(new FooterLine(raw, enc, keyStart, keyEnd, valStart, valEnd));
+ }
+
+ return r;
+ }
+
+ /**
+ * Get the values of all footer lines with the given key.
+ *
+ * @param footers
+ * list of footers to find the values in.
+ * @param keyName
+ * footer key to find values of, case-insensitive.
+ * @return values of footers with key of {@code keyName}, ordered by their
+ * order of appearance. Duplicates may be returned if the same
+ * footer appeared more than once. Empty list if no footers appear
+ * with the specified key, or there are no footers at all.
+ * @see #fromMessage
+ * @since 6.7
+ */
+ public static List<String> getValues(List<FooterLine> footers, String keyName) {
+ return getValues(footers, new FooterKey(keyName));
+ }
+
+ /**
+ * Get the values of all footer lines with the given key.
+ *
+ * @param footers
+ * list of footers to find the values in.
+ * @param key
+ * footer key to find values of, case-insensitive.
+ * @return values of footers with key of {@code keyName}, ordered by their
+ * order of appearance. Duplicates may be returned if the same
+ * footer appeared more than once. Empty list if no footers appear
+ * with the specified key, or there are no footers at all.
+ * @see #fromMessage
+ * @since 6.7
+ */
+ public static List<String> getValues(List<FooterLine> footers, FooterKey key) {
+ if (footers.isEmpty())
+ return Collections.emptyList();
+ ArrayList<String> r = new ArrayList<>(footers.size());
+ for (FooterLine f : footers) {
+ if (f.matches(key))
+ r.add(f.getValue());
+ }
+ return r;
+ }
+
/**
* Whether keys match
*
@@ -90,7 +224,7 @@ public final class FooterLine {
* character encoding.
*/
public String getValue() {
- return RawParseUtils.decode(enc, buffer, valStart, valEnd);
+ return RawParseUtils.decode(enc, buffer, valStart, valEnd).replaceAll("\n +", " "); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
@@ -117,7 +251,28 @@ public final class FooterLine {
return RawParseUtils.decode(enc, buffer, lt, gt - 1);
}
- /** {@inheritDoc} */
+ /**
+ * @return start offset of the footer relative to the original raw message
+ * byte buffer
+ *
+ * @see #fromMessage(byte[])
+ * @since 6.9
+ */
+ public int getStartOffset() {
+ return keyStart;
+ }
+
+ /**
+ * @return end offset of the footer relative to the original raw message
+ * byte buffer
+ *
+ * @see #fromMessage(byte[])
+ * @since 6.9
+ */
+ public int getEndOffset() {
+ return valEnd;
+ }
+
@Override
public String toString() {
return getKey() + ": " + getValue(); //$NON-NLS-1$
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/Generator.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/Generator.java
index 3493dcfb47..d97812ff45 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/Generator.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/Generator.java
@@ -71,8 +71,11 @@ abstract class Generator {
*
* @return next available commit; null if no more are to be returned.
* @throws MissingObjectException
+ * if an object is missing
* @throws IncorrectObjectTypeException
+ * if an object has an unexpected type
* @throws IOException
+ * if an IO error occurred
*/
abstract RevCommit next() throws MissingObjectException,
IncorrectObjectTypeException, IOException;
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/LIFORevQueue.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/LIFORevQueue.java
index 4773ca8427..ae67ca7599 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/LIFORevQueue.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/LIFORevQueue.java
@@ -34,7 +34,6 @@ public class LIFORevQueue extends BlockRevQueue {
super(s);
}
- /** {@inheritDoc} */
@Override
public void add(RevCommit c) {
Block b = head;
@@ -47,7 +46,6 @@ public class LIFORevQueue extends BlockRevQueue {
b.unpop(c);
}
- /** {@inheritDoc} */
@Override
public RevCommit next() {
final Block b = head;
@@ -62,7 +60,6 @@ public class LIFORevQueue extends BlockRevQueue {
return c;
}
- /** {@inheritDoc} */
@Override
public void clear() {
head = null;
@@ -89,7 +86,6 @@ public class LIFORevQueue extends BlockRevQueue {
return false;
}
- /** {@inheritDoc} */
@Override
public String toString() {
final StringBuilder s = new StringBuilder();
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/MergeBaseGenerator.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/MergeBaseGenerator.java
index c0fea75777..be29dc3138 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/MergeBaseGenerator.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/MergeBaseGenerator.java
@@ -12,7 +12,7 @@ package org.eclipse.jgit.revwalk;
import java.io.IOException;
import java.text.MessageFormat;
-import java.util.LinkedList;
+import java.util.ArrayDeque;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
@@ -47,7 +47,8 @@ class MergeBaseGenerator extends Generator {
private int recarryTest;
private int recarryMask;
private int mergeBaseAncestor = -1;
- private LinkedList<RevCommit> ret = new LinkedList<>();
+
+ private ArrayDeque<RevCommit> ret = new ArrayDeque<>();
private CarryStack stack;
@@ -114,7 +115,7 @@ class MergeBaseGenerator extends Generator {
return null;
}
- for (RevCommit p : c.parents) {
+ for (RevCommit p : c.getParents()) {
if ((p.flags & IN_PENDING) != 0)
continue;
if ((p.flags & PARSED) == 0)
@@ -180,7 +181,7 @@ class MergeBaseGenerator extends Generator {
private void carryOntoHistoryInnerLoop(RevCommit c, int carry) {
for (;;) {
- RevCommit[] parents = c.parents;
+ RevCommit[] parents = c.getParents();
if (parents == null || parents.length == 0) {
break;
}
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/ObjectWalk.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/ObjectWalk.java
index e6f9580bf7..82671d9abb 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/ObjectWalk.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/ObjectWalk.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008, Shawn O. Pearce <[email protected]> and others
+ * Copyright (C) 2008, 2022 Shawn O. Pearce <[email protected]> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
@@ -139,7 +139,7 @@ public class ObjectWalk extends RevWalk {
* the repository the walker will obtain data from.
*/
public ObjectWalk(Repository repo) {
- this(repo.newObjectReader());
+ this(repo.newObjectReader(), true);
}
/**
@@ -151,7 +151,11 @@ public class ObjectWalk extends RevWalk {
* required.
*/
public ObjectWalk(ObjectReader or) {
- super(or);
+ this(or, false);
+ }
+
+ private ObjectWalk(ObjectReader or, boolean closeReader) {
+ super(or, closeReader);
setRetainBody(false);
rootObjects = new ArrayList<>();
pendingObjects = new BlockObjQueue();
@@ -296,14 +300,12 @@ public class ObjectWalk extends RevWalk {
addObject(o);
}
- /** {@inheritDoc} */
@Override
public void sort(RevSort s) {
super.sort(s);
boundary = hasRevSort(RevSort.BOUNDARY);
}
- /** {@inheritDoc} */
@Override
public void sort(RevSort s, boolean use) {
super.sort(s, use);
@@ -353,7 +355,6 @@ public class ObjectWalk extends RevWalk {
visitationPolicy = requireNonNull(policy);
}
- /** {@inheritDoc} */
@Override
public RevCommit next() throws MissingObjectException,
IncorrectObjectTypeException, IOException {
@@ -641,6 +642,8 @@ public class ObjectWalk extends RevWalk {
}
/**
+ * Get the current traversal depth from the root tree object
+ *
* @return the current traversal depth from the root tree object
* @since 5.4
*/
@@ -758,7 +761,6 @@ public class ObjectWalk extends RevWalk {
pathBuf = newBuf;
}
- /** {@inheritDoc} */
@Override
public void dispose() {
super.dispose();
@@ -767,7 +769,6 @@ public class ObjectWalk extends RevWalk {
freeVisit = null;
}
- /** {@inheritDoc} */
@Override
protected void reset(int retainFlags) {
super.reset(retainFlags);
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/PendingGenerator.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/PendingGenerator.java
index add387de03..a49f787316 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/PendingGenerator.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/PendingGenerator.java
@@ -108,8 +108,9 @@ class PendingGenerator extends Generator {
produce = filter.include(walker, c);
}
- for (int i = 0; i < c.parents.length; i++) {
- RevCommit p = c.parents[i];
+ int parentCount = c.getParentCount();
+ for (int i = 0; i < parentCount; i++) {
+ RevCommit p = c.getParent(i);
// If the commit is uninteresting, don't try to prune
// parents because we want the maximal uninteresting set.
if (firstParent && i > 0 && (c.flags & UNINTERESTING) == 0) {
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/ReachabilityChecker.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/ReachabilityChecker.java
index d499084b42..1a869a0703 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/ReachabilityChecker.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/ReachabilityChecker.java
@@ -28,7 +28,7 @@ import org.eclipse.jgit.errors.MissingObjectException;
public interface ReachabilityChecker {
/**
- * Check if all targets are reachable from the {@code starter} commits.
+ * Check if all targets are reachable from the {@code starters} commits.
* <p>
* Caller should parse the objectIds (preferably with
* {@code walk.parseCommit()} and handle missing/incorrect type objects
@@ -61,7 +61,7 @@ public interface ReachabilityChecker {
}
/**
- * Check if all targets are reachable from the {@code starter} commits.
+ * Check if all targets are reachable from the {@code starters} commits.
* <p>
* Caller should parse the objectIds (preferably with
* {@code walk.parseCommit()} and handle missing/incorrect type objects
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/RenameCallback.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/RenameCallback.java
index ba3399ce9f..9856f2c252 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/RenameCallback.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/RenameCallback.java
@@ -23,8 +23,30 @@ public abstract class RenameCallback {
* Called whenever a diff was found that is actually a rename or copy of a
* file.
*
+ * <p>Subclass of this class have to override this to receive diffEntry for
+ * the rename.
+ *
* @param entry
* the entry representing the rename/copy
*/
public abstract void renamed(DiffEntry entry);
+
+ /**
+ * Called whenever a diff was found that is actually a rename or copy of a
+ * file along with the commit that caused it.
+ *
+ * <p>Subclass of this class have an option to override this if it wants to
+ * know what commit generated the diffEntry. Otherwise defaults to the
+ * {@link RenameCallback#renamed(DiffEntry)} function.
+ *
+ * @param entry
+ * the entry representing the rename/copy
+ * @param commit
+ * commit at which callback occurred
+ *
+ * @since 6.7
+ */
+ public void renamed(DiffEntry entry, RevCommit commit) {
+ renamed(entry);
+ }
}
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevBlob.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevBlob.java
index f5abbb870a..1f81b6a922 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevBlob.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevBlob.java
@@ -33,7 +33,6 @@ public class RevBlob extends RevObject {
super(id);
}
- /** {@inheritDoc} */
@Override
public final int getType() {
return Constants.OBJ_BLOB;
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevCommit.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevCommit.java
index 82725f3db9..b2eed83c65 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevCommit.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevCommit.java
@@ -11,20 +11,18 @@
package org.eclipse.jgit.revwalk;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.util.RawParseUtils.guessEncoding;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
+import org.eclipse.jgit.internal.storage.commitgraph.ChangedPathFilter;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.MutableObjectId;
@@ -36,7 +34,13 @@ import org.eclipse.jgit.util.StringUtils;
/**
* A commit reference to a commit in the DAG.
+ *
+ * The state of the RevCommit isn't populated until the commit is parsed. The
+ * newly created RevCommit is unparsed and only has an objectId reference. Other
+ * states like parents, trees, commit ident, commit message, etc. are
+ * populated/available when the commit is parsed.
*/
+@SuppressWarnings("deprecation")
public class RevCommit extends RevObject {
private static final int STACK_DEPTH = 500;
@@ -100,15 +104,35 @@ public class RevCommit extends RevObject {
static final RevCommit[] NO_PARENTS = {};
- private RevTree tree;
+ /**
+ * Tree reference of the commit.
+ *
+ * @since 6.5
+ */
+ protected RevTree tree;
- RevCommit[] parents;
+ /**
+ * Avoid accessing this field directly. Use method
+ * {@link RevCommit#getParents()} instead. RevCommit does not allow parents
+ * to be overridden and altering parent(s) is not supported.
+ *
+ * @since 6.3
+ */
+ protected RevCommit[] parents;
int commitTime; // An int here for performance, overflows in 2038
int inDegree;
- private byte[] buffer;
+ /**
+ * Raw unparsed commit body of the commit. Populated only
+ * after {@link #parseCanonical(RevWalk, byte[])} with
+ * {@link RevWalk#isRetainBody()} enable or after
+ * {@link #parseBody(RevWalk)} and {@link #parse(RevWalk, byte[])}.
+ *
+ * @since 6.5.1
+ */
+ protected byte[] buffer;
/**
* Create a new commit reference.
@@ -146,7 +170,7 @@ public class RevCommit extends RevObject {
tree = walk.lookupTree(idBuffer);
int ptr = 46;
- if (parents == null) {
+ if (getParents() == null) {
RevCommit[] pList = new RevCommit[1];
int nParents = 0;
for (;;) {
@@ -197,7 +221,6 @@ public class RevCommit extends RevObject {
flags |= PARSED;
}
- /** {@inheritDoc} */
@Override
public final int getType() {
return Constants.OBJ_COMMIT;
@@ -210,8 +233,8 @@ public class RevCommit extends RevObject {
}
private static FIFORevQueue carryFlags1(RevCommit c, int carry, int depth) {
- for(;;) {
- RevCommit[] pList = c.parents;
+ for (;;) {
+ RevCommit[] pList = c.getParents();
if (pList == null || pList.length == 0)
return null;
if (pList.length != 1) {
@@ -259,7 +282,7 @@ public class RevCommit extends RevObject {
// Commits in q have non-null parent arrays and have set all
// flags in carry. This loop finishes copying over the graph.
for (RevCommit c; (c = q.next()) != null;) {
- for (RevCommit p : c.parents)
+ for (RevCommit p : c.getParents())
carryOneStep(q, carry, p);
}
}
@@ -267,7 +290,7 @@ public class RevCommit extends RevObject {
private static void carryOneStep(FIFORevQueue q, int carry, RevCommit c) {
if ((c.flags & carry) != carry) {
c.flags |= carry;
- if (c.parents != null)
+ if (c.getParents() != null)
q.add(c);
}
}
@@ -313,8 +336,8 @@ public class RevCommit extends RevObject {
*
* @return number of parents; always a positive value but can be 0.
*/
- public final int getParentCount() {
- return parents.length;
+ public int getParentCount() {
+ return parents == null ? 0 : parents.length;
}
/**
@@ -327,7 +350,7 @@ public class RevCommit extends RevObject {
* @throws java.lang.ArrayIndexOutOfBoundsException
* an invalid parent index was specified.
*/
- public final RevCommit getParent(int nth) {
+ public RevCommit getParent(int nth) {
return parents[nth];
}
@@ -341,7 +364,7 @@ public class RevCommit extends RevObject {
*
* @return the array of parents.
*/
- public final RevCommit[] getParents() {
+ public RevCommit[] getParents() {
return parents;
}
@@ -353,9 +376,9 @@ public class RevCommit extends RevObject {
* this buffer should be very careful to ensure they do not modify its
* contents during their use of it.
*
- * @return the raw unparsed commit body. This is <b>NOT A COPY</b>.
- * Altering the contents of this buffer may alter the walker's
- * knowledge of this commit, and the results it produces.
+ * @return the raw unparsed commit body. This is <b>NOT A COPY</b>. Altering
+ * the contents of this buffer may alter the walker's knowledge of
+ * this commit, and the results it produces.
*/
public final byte[] getRawBuffer() {
return buffer;
@@ -380,13 +403,13 @@ public class RevCommit extends RevObject {
*/
public final byte[] getRawGpgSignature() {
final byte[] raw = buffer;
- final byte[] header = {'g', 'p', 'g', 's', 'i', 'g'};
+ final byte[] header = { 'g', 'p', 'g', 's', 'i', 'g' };
final int start = RawParseUtils.headerStart(header, raw, 0);
if (start < 0) {
return null;
}
final int end = RawParseUtils.headerEnd(raw, start);
- return Arrays.copyOfRange(raw, start, end);
+ return RawParseUtils.headerValue(raw, start, end);
}
/**
@@ -459,7 +482,8 @@ public class RevCommit extends RevObject {
if (msgB < 0) {
return ""; //$NON-NLS-1$
}
- return RawParseUtils.decode(guessEncoding(), raw, msgB, raw.length);
+ return RawParseUtils.decode(guessEncoding(buffer), raw, msgB,
+ raw.length);
}
/**
@@ -485,7 +509,8 @@ public class RevCommit extends RevObject {
}
int msgE = RawParseUtils.endOfParagraph(raw, msgB);
- String str = RawParseUtils.decode(guessEncoding(), raw, msgB, msgE);
+ String str = RawParseUtils.decode(guessEncoding(buffer), raw, msgB,
+ msgE);
if (hasLF(raw, msgB, msgE)) {
str = StringUtils.replaceLineBreaksWithSpace(str);
}
@@ -537,14 +562,6 @@ public class RevCommit extends RevObject {
return RawParseUtils.parseEncoding(buffer);
}
- private Charset guessEncoding() {
- try {
- return getEncoding();
- } catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
- return UTF_8;
- }
- }
-
/**
* Parse the footer lines (e.g. "Signed-off-by") for machine processing.
* <p>
@@ -553,8 +570,9 @@ public class RevCommit extends RevObject {
* the order of the line's appearance in the commit message itself.
* <p>
* A footer line's key must match the pattern {@code ^[A-Za-z0-9-]+:}, while
- * the value is free-form, but must not contain an LF. Very common keys seen
- * in the wild are:
+ * the value is free-form. The Value may be split over multiple lines with
+ * each subsequent line starting with at least one whitespace. Very common
+ * keys seen in the wild are:
* <ul>
* <li>{@code Signed-off-by} (agrees to Developer Certificate of Origin)
* <li>{@code Acked-by} (thinks change looks sane in context)
@@ -567,50 +585,14 @@ public class RevCommit extends RevObject {
* @return ordered list of footer lines; empty list if no footers found.
*/
public final List<FooterLine> getFooterLines() {
- final byte[] raw = buffer;
- int ptr = raw.length - 1;
- while (raw[ptr] == '\n') // trim any trailing LFs, not interesting
- ptr--;
-
- final int msgB = RawParseUtils.commitMessage(raw, 0);
- final ArrayList<FooterLine> r = new ArrayList<>(4);
- final Charset enc = guessEncoding();
- for (;;) {
- ptr = RawParseUtils.prevLF(raw, ptr);
- if (ptr <= msgB)
- break; // Don't parse commit headers as footer lines.
-
- final int keyStart = ptr + 2;
- if (raw[keyStart] == '\n')
- break; // Stop at first paragraph break, no footers above it.
-
- final int keyEnd = RawParseUtils.endOfFooterLineKey(raw, keyStart);
- if (keyEnd < 0)
- continue; // Not a well formed footer line, skip it.
-
- // Skip over the ': *' at the end of the key before the value.
- //
- int valStart = keyEnd + 1;
- while (valStart < raw.length && raw[valStart] == ' ')
- valStart++;
-
- // Value ends at the LF, and does not include it.
- //
- int valEnd = RawParseUtils.nextLF(raw, valStart);
- if (raw[valEnd - 1] == '\n')
- valEnd--;
-
- r.add(new FooterLine(raw, enc, keyStart, keyEnd, valStart, valEnd));
- }
- Collections.reverse(r);
- return r;
+ return FooterLine.fromMessage(buffer);
}
/**
* Get the values of all footer lines with the given key.
*
* @param keyName
- * footer key to find values of, case insensitive.
+ * footer key to find values of, case-insensitive.
* @return values of footers with key of {@code keyName}, ordered by their
* order of appearance. Duplicates may be returned if the same
* footer appeared more than once. Empty list if no footers appear
@@ -618,30 +600,55 @@ public class RevCommit extends RevObject {
* @see #getFooterLines()
*/
public final List<String> getFooterLines(String keyName) {
- return getFooterLines(new FooterKey(keyName));
+ return FooterLine.getValues(getFooterLines(), keyName);
}
/**
* Get the values of all footer lines with the given key.
*
- * @param keyName
- * footer key to find values of, case insensitive.
+ * @param key
+ * footer key to find values of, case-insensitive.
* @return values of footers with key of {@code keyName}, ordered by their
* order of appearance. Duplicates may be returned if the same
* footer appeared more than once. Empty list if no footers appear
* with the specified key, or there are no footers at all.
* @see #getFooterLines()
*/
- public final List<String> getFooterLines(FooterKey keyName) {
- final List<FooterLine> src = getFooterLines();
- if (src.isEmpty())
- return Collections.emptyList();
- final ArrayList<String> r = new ArrayList<>(src.size());
- for (FooterLine f : src) {
- if (f.matches(keyName))
- r.add(f.getValue());
- }
- return r;
+ public final List<String> getFooterLines(FooterKey key) {
+ return FooterLine.getValues(getFooterLines(), key);
+ }
+
+ /**
+ * Get the distance of the commit from the root, as defined in
+ * {@link org.eclipse.jgit.internal.storage.commitgraph.CommitGraph}
+ * <p>
+ * Generation number is
+ * {@link org.eclipse.jgit.lib.Constants#COMMIT_GENERATION_UNKNOWN} when the
+ * commit is not in the commit-graph. If a commit-graph file was written by
+ * a version of Git that did not compute generation numbers, then those
+ * commits in commit-graph will have generation number represented by
+ * {@link org.eclipse.jgit.lib.Constants#COMMIT_GENERATION_NOT_COMPUTED}.
+ *
+ * @return the generation number
+ * @since 6.5
+ */
+ int getGeneration() {
+ return Constants.COMMIT_GENERATION_UNKNOWN;
+ }
+
+ /**
+ * Get the changed path filter of the commit.
+ * <p>
+ * This is null when there is no commit graph file, the commit is not in the
+ * commit graph file, or the commit graph file was generated without changed
+ * path filters.
+ *
+ * @param rw A revwalk to load the commit graph (if available)
+ * @return the changed path filter
+ * @since 6.7
+ */
+ public ChangedPathFilter getChangedPathFilter(RevWalk rw) {
+ return null;
}
/**
@@ -670,7 +677,6 @@ public class RevCommit extends RevObject {
buffer = null;
}
- /** {@inheritDoc} */
@Override
public String toString() {
final StringBuilder s = new StringBuilder();
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevCommitCG.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevCommitCG.java
new file mode 100644
index 0000000000..c7a03992b7
--- /dev/null
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevCommitCG.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2023, Tencent.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v. 1.0 which is available at
+ * https://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+package org.eclipse.jgit.revwalk;
+
+import java.io.IOException;
+
+import org.eclipse.jgit.errors.IncorrectObjectTypeException;
+import org.eclipse.jgit.errors.MissingObjectException;
+import org.eclipse.jgit.internal.storage.commitgraph.ChangedPathFilter;
+import org.eclipse.jgit.internal.storage.commitgraph.CommitGraph;
+import org.eclipse.jgit.lib.AnyObjectId;
+import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.ObjectId;
+
+/**
+ * RevCommit parsed from
+ * {@link org.eclipse.jgit.internal.storage.commitgraph.CommitGraph}.
+ *
+ * @since 6.5
+ */
+class RevCommitCG extends RevCommit {
+
+ private final int graphPosition;
+
+ private int generation = Constants.COMMIT_GENERATION_UNKNOWN;
+
+ /**
+ * Create a new commit reference.
+ *
+ * @param id
+ * object name for the commit.
+ * @param graphPosition
+ * the position in the commit-graph of the object.
+ */
+ protected RevCommitCG(AnyObjectId id, int graphPosition) {
+ super(id);
+ this.graphPosition = graphPosition;
+ }
+
+ @Override
+ void parseCanonical(RevWalk walk, byte[] raw) throws IOException {
+ if (walk.isRetainBody()) {
+ buffer = raw;
+ }
+ parseInGraph(walk);
+ }
+
+ @Override
+ void parseHeaders(RevWalk walk) throws MissingObjectException,
+ IncorrectObjectTypeException, IOException {
+ if (walk.isRetainBody()) {
+ super.parseBody(walk); // This parses header and body
+ return;
+ }
+ parseInGraph(walk);
+ }
+
+ private void parseInGraph(RevWalk walk) throws IOException {
+ CommitGraph graph = walk.commitGraph();
+ CommitGraph.CommitData data = graph.getCommitData(graphPosition);
+ if (data == null) {
+ // RevCommitCG was created because we got its graphPosition from
+ // commit-graph. If now the commit-graph doesn't know about it,
+ // something went wrong.
+ throw new IllegalStateException();
+ }
+ if (!walk.shallowCommitsInitialized) {
+ walk.initializeShallowCommits(this);
+ }
+
+ this.tree = walk.lookupTree(data.getTree());
+ this.commitTime = (int) data.getCommitTime();
+ this.generation = data.getGeneration();
+
+ if (getParents() == null) {
+ int[] pGraphList = data.getParents();
+ if (pGraphList.length == 0) {
+ this.parents = RevCommit.NO_PARENTS;
+ } else {
+ RevCommit[] pList = new RevCommit[pGraphList.length];
+ for (int i = 0; i < pList.length; i++) {
+ int graphPos = pGraphList[i];
+ ObjectId objId = graph.getObjectId(graphPos);
+ pList[i] = walk.lookupCommit(objId, graphPos);
+ }
+ this.parents = pList;
+ }
+ }
+ flags |= PARSED;
+ }
+
+ @Override
+ int getGeneration() {
+ return generation;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public ChangedPathFilter getChangedPathFilter(RevWalk rw) {
+ return rw.commitGraph().getChangedPathFilter(graphPosition);
+ }
+}
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevCommitList.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevCommitList.java
index 59213a8e60..58f5d425cc 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevCommitList.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevCommitList.java
@@ -25,7 +25,6 @@ import org.eclipse.jgit.revwalk.filter.RevFilter;
public class RevCommitList<E extends RevCommit> extends RevObjectList<E> {
private RevWalk walker;
- /** {@inheritDoc} */
@Override
public void clear() {
super.clear();
@@ -313,7 +312,6 @@ public class RevCommitList<E extends RevCommit> extends RevObjectList<E> {
* walker specified by {@link #source(RevWalk)} is pumped until the
* specified commit is loaded. Callers can test the final size of the list
* by {@link #size()} to determine if the high water mark specified was met.
- * <p>
*
* @param commitToLoad
* commit the caller wants this list to contain when the fill
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevFlag.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevFlag.java
index a0160ddbef..3221bf6e8f 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevFlag.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevFlag.java
@@ -67,7 +67,6 @@ public class RevFlag {
return walker;
}
- /** {@inheritDoc} */
@Override
public String toString() {
return name;
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevFlagSet.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevFlagSet.java
index 71cc9a4850..6a98249892 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevFlagSet.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevFlagSet.java
@@ -104,7 +104,7 @@ public class RevFlagSet extends AbstractSet<RevFlag> {
@Override
public Iterator<RevFlag> iterator() {
final Iterator<RevFlag> i = active.iterator();
- return new Iterator<RevFlag>() {
+ return new Iterator<>() {
private RevFlag current;
@Override
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevObject.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevObject.java
index 4d2684a0f0..55ea30d24b 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevObject.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevObject.java
@@ -132,7 +132,6 @@ public abstract class RevObject extends ObjectIdOwnerMap.Entry {
flags &= ~set.mask;
}
- /** {@inheritDoc} */
@Override
public String toString() {
final StringBuilder s = new StringBuilder();
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevObjectList.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevObjectList.java
index 0393f55957..ad8aeedeb9 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevObjectList.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevObjectList.java
@@ -47,7 +47,6 @@ public class RevObjectList<E extends RevObject> extends AbstractList<E> {
// Initialized above.
}
- /** {@inheritDoc} */
@Override
public void add(int index, E element) {
if (index != size)
@@ -58,7 +57,6 @@ public class RevObjectList<E extends RevObject> extends AbstractList<E> {
size++;
}
- /** {@inheritDoc} */
@Override
@SuppressWarnings("unchecked")
public E set(int index, E element) {
@@ -80,7 +78,6 @@ public class RevObjectList<E extends RevObject> extends AbstractList<E> {
return (E) old;
}
- /** {@inheritDoc} */
@Override
@SuppressWarnings("unchecked")
public E get(int index) {
@@ -95,13 +92,11 @@ public class RevObjectList<E extends RevObject> extends AbstractList<E> {
return s != null ? (E) s.contents[index] : null;
}
- /** {@inheritDoc} */
@Override
public int size() {
return size;
}
- /** {@inheritDoc} */
@Override
public void clear() {
contents = new Block(0);
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevTag.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevTag.java
index b5d74ba747..75dbd57740 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevTag.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevTag.java
@@ -39,7 +39,7 @@ import org.eclipse.jgit.util.StringUtils;
public class RevTag extends RevObject {
private static final byte[] hSignature = Constants
- .encodeASCII("-----BEGIN "); //$NON-NLS-1$
+ .encodeASCII("-----BEGIN PGP SIGNATURE-----"); //$NON-NLS-1$
/**
* Parse an annotated tag from its canonical format.
@@ -149,7 +149,6 @@ public class RevTag extends RevObject {
flags |= PARSED;
}
- /** {@inheritDoc} */
@Override
public final int getType() {
return Constants.OBJ_TAG;
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevTree.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevTree.java
index 8119af468a..d81af0c029 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevTree.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevTree.java
@@ -33,7 +33,6 @@ public class RevTree extends RevObject {
super(id);
}
- /** {@inheritDoc} */
@Override
public final int getType() {
return Constants.OBJ_TREE;
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevWalk.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevWalk.java
index a297d5776d..666f12460a 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevWalk.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevWalk.java
@@ -12,13 +12,21 @@
package org.eclipse.jgit.revwalk;
+import static org.eclipse.jgit.internal.storage.commitgraph.CommitGraph.EMPTY;
+
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import java.util.
+Optional;
+import java.util.Set;
import org.eclipse.jgit.annotations.NonNull;
import org.eclipse.jgit.annotations.Nullable;
@@ -30,6 +38,7 @@ import org.eclipse.jgit.errors.RevWalkException;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.lib.AnyObjectId;
import org.eclipse.jgit.lib.AsyncObjectLoaderQueue;
+import org.eclipse.jgit.internal.storage.commitgraph.CommitGraph;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.MutableObjectId;
import org.eclipse.jgit.lib.NullProgressMonitor;
@@ -70,6 +79,7 @@ import org.eclipse.jgit.util.References;
* the same RevWalk at the same time. The Iterator may buffer RevCommits, while
* {@link #next()} does not.
*/
+@SuppressWarnings("rawtypes")
public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
private static final int MB = 1 << 20;
@@ -143,8 +153,21 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
*/
static final int TOPO_QUEUED = 1 << 6;
- /** Number of flag bits we keep internal for our own use. See above flags. */
- static final int RESERVED_FLAGS = 7;
+ /**
+ * Set on a RevCommit when a {@link TreeRevFilter} has been applied.
+ * <p>
+ * This flag is processed by the {@link RewriteGenerator} to check if a
+ * {@link TreeRevFilter} has been applied.
+ *
+ * @see TreeRevFilter
+ * @see RewriteGenerator
+ */
+ static final int TREE_REV_FILTER_APPLIED = 1 << 7;
+
+ /**
+ * Number of flag bits we keep internal for our own use. See above flags.
+ */
+ static final int RESERVED_FLAGS = 8;
private static final int APP_FLAGS = -1 & ~((1 << RESERVED_FLAGS) - 1);
@@ -176,6 +199,8 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
private TreeFilter treeFilter;
+ private CommitGraph commitGraph;
+
private boolean retainBody = true;
private boolean rewriteParents = true;
@@ -185,9 +210,7 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
boolean shallowCommitsInitialized;
private enum GetMergedIntoStrategy {
- RETURN_ON_FIRST_FOUND,
- RETURN_ON_FIRST_NOT_FOUND,
- EVALUATE_ALL
+ RETURN_ON_FIRST_FOUND, RETURN_ON_FIRST_NOT_FOUND, EVALUATE_ALL
}
/**
@@ -204,28 +227,51 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
/**
* Create a new revision walker for a given repository.
- * <p>
*
* @param or
* the reader the walker will obtain data from. The reader is not
- * closed when the walker is closed (but is closed by {@link
- * #dispose()}.
+ * closed when the walker is closed (but is closed by
+ * {@link #dispose()}.
*/
public RevWalk(ObjectReader or) {
this(or, false);
}
- private RevWalk(ObjectReader or, boolean closeReader) {
+ RevWalk(ObjectReader or, boolean closeReader) {
reader = or;
idBuffer = new MutableObjectId();
objects = new ObjectIdOwnerMap<>();
roots = new ArrayList<>();
- queue = new DateRevQueue(false);
+ queue = newDateRevQueue(false);
pending = new StartGenerator(this);
sorting = EnumSet.of(RevSort.NONE);
filter = RevFilter.ALL;
treeFilter = TreeFilter.ALL;
this.closeReader = closeReader;
+ commitGraph = null;
+ }
+
+ static AbstractRevQueue newDateRevQueue(boolean firstParent) {
+ if(usePriorityQueue()) {
+ return new DateRevPriorityQueue(firstParent);
+ }
+
+ return new DateRevQueue(firstParent);
+ }
+
+ static DateRevQueue newDateRevQueue(Generator g) throws IOException {
+ if(usePriorityQueue()) {
+ return new DateRevPriorityQueue(g);
+ }
+
+ return new DateRevQueue(g);
+ }
+
+ private static boolean usePriorityQueue() {
+ return Optional
+ .ofNullable(System.getProperty("REVWALK_USE_PRIORITY_QUEUE")) //$NON-NLS-1$
+ .map(Boolean::parseBoolean)
+ .orElse(false);
}
/**
@@ -370,9 +416,8 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
* @throws java.io.IOException
* a pack file or loose object could not be read.
*/
- public void markUninteresting(RevCommit c)
- throws MissingObjectException, IncorrectObjectTypeException,
- IOException {
+ public void markUninteresting(RevCommit c) throws MissingObjectException,
+ IncorrectObjectTypeException, IOException {
c.flags |= UNINTERESTING;
carryFlagsImpl(c);
markStart(c);
@@ -381,8 +426,8 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
/**
* Determine if a commit is reachable from another commit.
* <p>
- * A commit <code>base</code> is an ancestor of <code>tip</code> if we
- * can find a path of commits that leads from <code>tip</code> and ends at
+ * A commit <code>base</code> is an ancestor of <code>tip</code> if we can
+ * find a path of commits that leads from <code>tip</code> and ends at
* <code>base</code>.
* <p>
* This utility function resets the walker, inserts the two supplied
@@ -438,7 +483,6 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
* <p>
* A commit is merged into a ref if we can find a path of commits that leads
* from that specific ref and ends at <code>commit</code>.
- * <p>
*
* @param commit
* commit the caller thinks is reachable from <code>refs</code>.
@@ -451,7 +495,7 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
* @since 5.12
*/
public List<Ref> getMergedInto(RevCommit commit, Collection<Ref> refs)
- throws IOException{
+ throws IOException {
return getMergedInto(commit, refs, NullProgressMonitor.INSTANCE);
}
@@ -460,7 +504,6 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
* <p>
* A commit is merged into a ref if we can find a path of commits that leads
* from that specific ref and ends at <code>commit</code>.
- * <p>
*
* @param commit
* commit the caller thinks is reachable from <code>refs</code>.
@@ -475,9 +518,8 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
* @since 5.12
*/
public List<Ref> getMergedInto(RevCommit commit, Collection<Ref> refs,
- ProgressMonitor monitor) throws IOException{
- return getMergedInto(commit, refs,
- GetMergedIntoStrategy.EVALUATE_ALL,
+ ProgressMonitor monitor) throws IOException {
+ return getMergedInto(commit, refs, GetMergedIntoStrategy.EVALUATE_ALL,
monitor);
}
@@ -502,6 +544,27 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
NullProgressMonitor.INSTANCE).size() > 0;
}
+ /**
+ * Determine if a <code>commit</code> is merged into any of the given
+ * <code>revs</code>.
+ *
+ * @param commit
+ * commit the caller thinks is reachable from <code>revs</code>.
+ * @param revs
+ * commits to start iteration from, and which is most likely a
+ * descendant (child) of <code>commit</code>.
+ * @return true if commit is merged into any of the revs; false otherwise.
+ * @throws java.io.IOException
+ * a pack file or loose object could not be read.
+ * @since 6.10.1
+ */
+ public boolean isMergedIntoAnyCommit(RevCommit commit, Collection<RevCommit> revs)
+ throws IOException {
+ return getCommitsMergedInto(commit, revs,
+ GetMergedIntoStrategy.RETURN_ON_FIRST_FOUND,
+ NullProgressMonitor.INSTANCE).size() > 0;
+ }
+
/**
* Determine if a <code>commit</code> is merged into all of the given
* <code>refs</code>.
@@ -520,15 +583,33 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
throws IOException {
return getMergedInto(commit, refs,
GetMergedIntoStrategy.RETURN_ON_FIRST_NOT_FOUND,
- NullProgressMonitor.INSTANCE).size()
- == refs.size();
+ NullProgressMonitor.INSTANCE).size() == refs.size();
}
- @SuppressWarnings("rawtypes")
private List<Ref> getMergedInto(RevCommit needle, Collection<Ref> haystacks,
- Enum returnStrategy, ProgressMonitor monitor) throws IOException {
+ Enum returnStrategy, ProgressMonitor monitor) throws IOException {
+ Map<RevCommit, List<Ref>> refsByCommit = new HashMap<>();
+ for (Ref r : haystacks) {
+ RevObject o = peel(parseAny(r.getObjectId()));
+ if (!(o instanceof RevCommit)) {
+ continue;
+ }
+ refsByCommit.computeIfAbsent((RevCommit) o, c -> new ArrayList<>()).add(r);
+ }
+ monitor.update(1);
List<Ref> result = new ArrayList<>();
+ for (RevCommit c : getCommitsMergedInto(needle, refsByCommit.keySet(),
+ returnStrategy, monitor)) {
+ result.addAll(refsByCommit.get(c));
+ }
+ return result;
+ }
+
+ private Set<RevCommit> getCommitsMergedInto(RevCommit needle, Collection<RevCommit> haystacks,
+ Enum returnStrategy, ProgressMonitor monitor) throws IOException {
+ Set<RevCommit> result = new HashSet<>();
List<RevCommit> uninteresting = new ArrayList<>();
+ List<RevCommit> marked = new ArrayList<>();
RevFilter oldRF = filter;
TreeFilter oldTF = treeFilter;
try {
@@ -536,31 +617,39 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
reset(~freeFlags & APP_FLAGS);
filter = RevFilter.ALL;
treeFilter = TreeFilter.ALL;
- for (Ref r: haystacks) {
+
+ // Make sure commit is parsed from commit-graph
+ if ((needle.flags & PARSED) == 0) {
+ needle.parseHeaders(this);
+ }
+ int cutoff = needle.getGeneration();
+ for (RevCommit c : haystacks) {
if (monitor.isCancelled()) {
return result;
}
monitor.update(1);
- RevObject o = parseAny(r.getObjectId());
- if (!(o instanceof RevCommit)) {
- continue;
- }
- RevCommit c = (RevCommit) o;
- resetRetain(RevFlag.UNINTERESTING);
+ reset(UNINTERESTING | TEMP_MARK);
markStart(c);
boolean commitFound = false;
RevCommit next;
while ((next = next()) != null) {
- if (References.isSameObject(next, needle)) {
- result.add(r);
+ if (next.getGeneration() < cutoff) {
+ markUninteresting(next);
+ uninteresting.add(next);
+ }
+ if (References.isSameObject(next, needle)
+ || (next.flags & TEMP_MARK) != 0) {
+ result.add(c);
if (returnStrategy == GetMergedIntoStrategy.RETURN_ON_FIRST_FOUND) {
return result;
}
commitFound = true;
+ c.flags |= TEMP_MARK;
+ marked.add(c);
break;
}
}
- if(!commitFound){
+ if (!commitFound) {
markUninteresting(c);
uninteresting.add(c);
if (returnStrategy == GetMergedIntoStrategy.RETURN_ON_FIRST_NOT_FOUND) {
@@ -572,6 +661,9 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
roots.addAll(uninteresting);
filter = oldRF;
treeFilter = oldTF;
+ for (RevCommit c : marked) {
+ c.flags &= ~TEMP_MARK;
+ }
}
return result;
}
@@ -794,6 +886,8 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
}
/**
+ * Whether only first-parent links should be followed when walking
+ *
* @return whether only first-parent links should be followed when walking.
*
* @since 5.5
@@ -818,7 +912,7 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
assertNotStarted();
assertNoCommitsMarkedStart();
firstParent = enable;
- queue = new DateRevQueue(firstParent);
+ queue = newDateRevQueue(firstParent);
pending = new StartGenerator(this);
}
@@ -885,6 +979,29 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
return c;
}
+ /**
+ * This method is intended to be invoked only by {@link RevCommitCG}, in
+ * order to give commit the correct graphPosition before accessing the
+ * commit-graph. In this way, the headers of the commit can be obtained in
+ * constant time.
+ *
+ * @param id
+ * name of the commit object.
+ * @param graphPos
+ * the position in the commit-graph of the object.
+ * @return reference to the commit object. Never null.
+ * @since 6.5
+ */
+ @NonNull
+ protected RevCommit lookupCommit(AnyObjectId id, int graphPos) {
+ RevCommit c = (RevCommit) objects.get(id);
+ if (c == null) {
+ c = createCommit(id, graphPos);
+ objects.add(c);
+ }
+ return c;
+ }
+
/**
* Locate a reference to a tag without loading it.
* <p>
@@ -973,9 +1090,8 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
* a pack file or loose object could not be read.
*/
@NonNull
- public RevCommit parseCommit(AnyObjectId id)
- throws MissingObjectException, IncorrectObjectTypeException,
- IOException {
+ public RevCommit parseCommit(AnyObjectId id) throws MissingObjectException,
+ IncorrectObjectTypeException, IOException {
RevObject c = peel(parseAny(id));
if (!(c instanceof RevCommit))
throw new IncorrectObjectTypeException(id.toObjectId(),
@@ -1001,9 +1117,8 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
* a pack file or loose object could not be read.
*/
@NonNull
- public RevTree parseTree(AnyObjectId id)
- throws MissingObjectException, IncorrectObjectTypeException,
- IOException {
+ public RevTree parseTree(AnyObjectId id) throws MissingObjectException,
+ IncorrectObjectTypeException, IOException {
RevObject c = peel(parseAny(id));
final RevTree t;
@@ -1123,9 +1238,31 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
}
}
+ /**
+ * Get the commit-graph.
+ *
+ * @return the commit-graph. Never null.
+ * @since 6.5
+ */
+ @NonNull
+ CommitGraph commitGraph() {
+ if (commitGraph == null) {
+ try {
+ commitGraph = reader != null
+ ? reader.getCommitGraph().orElse(EMPTY)
+ : EMPTY;
+ } catch (IOException e) {
+ commitGraph = EMPTY;
+ }
+ }
+ return commitGraph;
+ }
+
/**
* Asynchronous object parsing.
*
+ * @param <T>
+ * Type of returned {@code ObjectId}
* @param objectIds
* objects to open from the object store. The supplied collection
* must not be modified until the queue has finished.
@@ -1257,8 +1394,8 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
* @throws java.io.IOException
* a pack file or loose object could not be read.
*/
- public RevObject peel(RevObject obj) throws MissingObjectException,
- IOException {
+ public RevObject peel(RevObject obj)
+ throws MissingObjectException, IOException {
while (obj instanceof RevTag) {
parseHeaders(obj);
obj = ((RevTag) obj).getObject();
@@ -1287,9 +1424,9 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
int allocFlag() {
if (freeFlags == 0)
- throw new IllegalArgumentException(MessageFormat.format(
- JGitText.get().flagsAlreadyCreated,
- Integer.valueOf(32 - RESERVED_FLAGS)));
+ throw new IllegalArgumentException(
+ MessageFormat.format(JGitText.get().flagsAlreadyCreated,
+ Integer.valueOf(32 - RESERVED_FLAGS)));
final int m = Integer.lowestOneBit(freeFlags);
freeFlags &= ~m;
return m;
@@ -1306,9 +1443,11 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
*/
public void carry(RevFlag flag) {
if ((freeFlags & flag.mask) != 0)
- throw new IllegalArgumentException(MessageFormat.format(JGitText.get().flagIsDisposed, flag.name));
+ throw new IllegalArgumentException(MessageFormat
+ .format(JGitText.get().flagIsDisposed, flag.name));
if (flag.walker != this)
- throw new IllegalArgumentException(MessageFormat.format(JGitText.get().flagNotFromThis, flag.name));
+ throw new IllegalArgumentException(MessageFormat
+ .format(JGitText.get().flagNotFromThis, flag.name));
carryFlags |= flag.mask;
}
@@ -1342,9 +1481,11 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
*/
public final void retainOnReset(RevFlag flag) {
if ((freeFlags & flag.mask) != 0)
- throw new IllegalArgumentException(MessageFormat.format(JGitText.get().flagIsDisposed, flag.name));
+ throw new IllegalArgumentException(MessageFormat
+ .format(JGitText.get().flagIsDisposed, flag.name));
if (flag.walker != this)
- throw new IllegalArgumentException(MessageFormat.format(JGitText.get().flagNotFromThis, flag.name));
+ throw new IllegalArgumentException(MessageFormat
+ .format(JGitText.get().flagNotFromThis, flag.name));
retainOnReset |= flag.mask;
}
@@ -1479,9 +1620,9 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
final RevCommit c = q.next();
if (c == null)
break;
- if (c.parents == null)
+ if (c.getParents() == null)
continue;
- for (RevCommit p : c.parents) {
+ for (RevCommit p : c.getParents()) {
if ((p.flags & clearFlags) == 0)
continue;
p.flags &= retainFlags;
@@ -1491,7 +1632,7 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
}
roots.clear();
- queue = new DateRevQueue(firstParent);
+ queue = newDateRevQueue(firstParent);
pending = new StartGenerator(this);
}
@@ -1512,7 +1653,7 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
firstParent = false;
objects.clear();
roots.clear();
- queue = new DateRevQueue(firstParent);
+ queue = newDateRevQueue(firstParent);
pending = new StartGenerator(this);
shallowCommitsInitialized = false;
}
@@ -1521,7 +1662,8 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
* Like {@link #next()}, but if a checked exception is thrown during the
* walk it is rethrown as a {@link RevWalkException}.
*
- * @throws RevWalkException if an {@link IOException} was thrown.
+ * @throws RevWalkException
+ * if an {@link IOException} was thrown.
* @return next most recent commit; null if traversal is over.
*/
@Nullable
@@ -1553,7 +1695,7 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
public Iterator<RevCommit> iterator() {
RevCommit first = nextForIterator();
- return new Iterator<RevCommit>() {
+ return new Iterator<>() {
RevCommit next = first;
@Override
@@ -1581,7 +1723,8 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
protected void assertNotStarted() {
if (isNotStarted())
return;
- throw new IllegalStateException(JGitText.get().outputHasAlreadyBeenStarted);
+ throw new IllegalStateException(
+ JGitText.get().outputHasAlreadyBeenStarted);
}
/**
@@ -1632,6 +1775,13 @@ public class RevWalk implements Iterable<RevCommit>, AutoCloseable {
* @return a new unparsed reference for the object.
*/
protected RevCommit createCommit(AnyObjectId id) {
+ return createCommit(id, commitGraph().findGraphPosition(id));
+ }
+
+ private RevCommit createCommit(AnyObjectId id, int graphPos) {
+ if (graphPos >= 0) {
+ return new RevCommitCG(id, graphPos);
+ }
return new RevCommit(id);
}
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevWalkUtils.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevWalkUtils.java
index e52e916318..4bfe2fda02 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/RevWalkUtils.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/RevWalkUtils.java
@@ -51,8 +51,11 @@ public final class RevWalkUtils {
* should be done until there are no more commits
* @return the number of commits
* @throws org.eclipse.jgit.errors.MissingObjectException
+ * if object is missing
* @throws org.eclipse.jgit.errors.IncorrectObjectTypeException
+ * if object has unexpected type
* @throws java.io.IOException
+ * if an IO error occurred
*/
public static int count(final RevWalk walk, final RevCommit start,
final RevCommit end) throws MissingObjectException,
@@ -80,8 +83,11 @@ public final class RevWalkUtils {
* should be done until there are no more commits
* @return the commits found
* @throws org.eclipse.jgit.errors.MissingObjectException
+ * if object is missing
* @throws org.eclipse.jgit.errors.IncorrectObjectTypeException
+ * if object has unexpected type
* @throws java.io.IOException
+ * if an IO error occurred
*/
public static List<RevCommit> find(final RevWalk walk,
final RevCommit start, final RevCommit end)
@@ -116,8 +122,11 @@ public final class RevWalkUtils {
* the set of branches we want to see reachability from
* @return the list of branches a given commit is reachable from
* @throws org.eclipse.jgit.errors.MissingObjectException
+ * if object is missing
* @throws org.eclipse.jgit.errors.IncorrectObjectTypeException
+ * if object has unexpected type
* @throws java.io.IOException
+ * if an IO error occurred
*/
public static List<Ref> findBranchesReachableFrom(RevCommit commit,
RevWalk revWalk, Collection<Ref> refs)
@@ -147,8 +156,11 @@ public final class RevWalkUtils {
* the callback for progress and cancellation
* @return the list of branches a given commit is reachable from
* @throws org.eclipse.jgit.errors.MissingObjectException
+ * if object is missing
* @throws org.eclipse.jgit.errors.IncorrectObjectTypeException
+ * if object has unexpected type
* @throws java.io.IOException
+ * if an IO error occurred
* @since 5.4
*/
public static List<Ref> findBranchesReachableFrom(RevCommit commit,
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/RewriteGenerator.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/RewriteGenerator.java
index a928c2e79b..4a93f4d745 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/RewriteGenerator.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/RewriteGenerator.java
@@ -24,14 +24,7 @@ import org.eclipse.jgit.errors.MissingObjectException;
* commit that matched the revision walker's filters.
* <p>
* This generator is the second phase of a path limited revision walk and
- * assumes it is receiving RevCommits from {@link TreeRevFilter},
- * after they have been fully buffered by {@link AbstractRevQueue}. The full
- * buffering is necessary to allow the simple loop used within our own
- * {@link #rewrite(RevCommit)} to pull completely through a strand of
- * {@link RevWalk#REWRITE} colored commits and come up with a simplification
- * that makes the DAG dense. Not fully buffering the commits first would cause
- * this loop to abort early, due to commits not being parsed and colored
- * correctly.
+ * assumes it is receiving RevCommits from {@link TreeRevFilter}.
*
* @see TreeRevFilter
*/
@@ -43,9 +36,12 @@ class RewriteGenerator extends Generator {
private final Generator source;
+ private final FIFORevQueue pending;
+
RewriteGenerator(Generator s) {
super(s.firstParent);
source = s;
+ pending = new FIFORevQueue(s.firstParent);
}
@Override
@@ -58,15 +54,25 @@ class RewriteGenerator extends Generator {
return source.outputType() & ~NEEDS_REWRITE;
}
+ @SuppressWarnings("ReferenceEquality")
@Override
RevCommit next() throws MissingObjectException,
IncorrectObjectTypeException, IOException {
- final RevCommit c = source.next();
+ RevCommit c = pending.next();
+
if (c == null) {
- return null;
+ c = source.next();
+ if (c == null) {
+ // We are done: Both the source generator and our internal list
+ // are completely exhausted.
+ return null;
+ }
}
+
+ applyFilterToParents(c);
+
boolean rewrote = false;
- final RevCommit[] pList = c.parents;
+ final RevCommit[] pList = c.getParents();
final int nParents = pList.length;
for (int i = 0; i < nParents; i++) {
final RevCommit oldp = pList[i];
@@ -90,10 +96,45 @@ class RewriteGenerator extends Generator {
return c;
}
- private RevCommit rewrite(RevCommit p) {
+ /**
+ * Makes sure that the {@link TreeRevFilter} has been applied to all parents
+ * of this commit by the previous {@link PendingGenerator}.
+ *
+ * @param c
+ * given commit
+ * @throws MissingObjectException
+ * if an object is missing
+ * @throws IncorrectObjectTypeException
+ * if an object has an unexpected type
+ * @throws IOException
+ * if an IO error occurred
+ */
+ private void applyFilterToParents(RevCommit c)
+ throws MissingObjectException, IncorrectObjectTypeException,
+ IOException {
+ for (RevCommit parent : c.getParents()) {
+ while ((parent.flags & RevWalk.TREE_REV_FILTER_APPLIED) == 0) {
+
+ RevCommit n = source.next();
+
+ if (n != null) {
+ pending.add(n);
+ } else {
+ // Source generator is exhausted; filter has been applied to
+ // all commits
+ return;
+ }
+
+ }
+
+ }
+ }
+
+ private RevCommit rewrite(RevCommit p) throws MissingObjectException,
+ IncorrectObjectTypeException, IOException {
for (;;) {
- final RevCommit[] pList = p.parents;
- if (pList.length > 1) {
+
+ if (p.getParentCount() > 1) {
// This parent is a merge, so keep it.
//
return p;
@@ -113,14 +154,16 @@ class RewriteGenerator extends Generator {
return p;
}
- if (pList.length == 0) {
+ if (p.getParentCount() == 0) {
// We can't go back any further, other than to
// just delete the parent entirely.
//
return null;
}
- p = pList[0];
+ applyFilterToParents(p.getParent(0));
+ p = p.getParent(0);
+
}
}
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/StartGenerator.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/StartGenerator.java
index bfcea6ea8f..6854b6083d 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/StartGenerator.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/StartGenerator.java
@@ -93,10 +93,11 @@ class StartGenerator extends Generator {
final DateRevQueue pending;
int pendingOutputType = 0;
- if (q instanceof DateRevQueue)
+ if (q instanceof DateRevQueue) {
pending = (DateRevQueue)q;
- else
- pending = new DateRevQueue(q);
+ } else {
+ pending = RevWalk.newDateRevQueue(q);
+ }
if (tf != TreeFilter.ALL) {
int rewriteFlag;
if (w.getRewriteParents()) {
@@ -125,12 +126,6 @@ class StartGenerator extends Generator {
}
if ((g.outputType() & NEEDS_REWRITE) != 0) {
- // Correction for an upstream NEEDS_REWRITE is to buffer
- // fully and then apply a rewrite generator that can
- // pull through the rewrite chain and produce a dense
- // output graph.
- //
- g = new FIFORevQueue(g);
g = new RewriteGenerator(g);
}
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/TopoNonIntermixSortGenerator.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/TopoNonIntermixSortGenerator.java
index 4f6d417ed1..c9d8ff90fd 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/TopoNonIntermixSortGenerator.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/TopoNonIntermixSortGenerator.java
@@ -33,8 +33,11 @@ class TopoNonIntermixSortGenerator extends Generator {
* @param s
* generator to pull all commits out of, and into this buffer.
* @throws MissingObjectException
+ * if an object is missing
* @throws IncorrectObjectTypeException
+ * if an object has an unexpected type
* @throws IOException
+ * if an IO error occurred
*/
TopoNonIntermixSortGenerator(Generator s) throws MissingObjectException,
IncorrectObjectTypeException, IOException {
@@ -48,7 +51,7 @@ class TopoNonIntermixSortGenerator extends Generator {
break;
}
if ((c.flags & TOPO_QUEUED) == 0) {
- for (RevCommit p : c.parents) {
+ for (RevCommit p : c.getParents()) {
p.inDegree++;
if (firstParent) {
@@ -94,7 +97,7 @@ class TopoNonIntermixSortGenerator extends Generator {
continue;
}
- for (RevCommit p : c.parents) {
+ for (RevCommit p : c.getParents()) {
if (--p.inDegree == 0 && (p.flags & TOPO_QUEUED) != 0) {
// The parent has no unproduced interesting children. unpop
// the parent so it goes right behind this child. This means
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/TopoSortGenerator.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/TopoSortGenerator.java
index 7a5db43a7a..950b0a45b4 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/TopoSortGenerator.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/TopoSortGenerator.java
@@ -33,8 +33,11 @@ class TopoSortGenerator extends Generator {
* @param s
* generator to pull all commits out of, and into this buffer.
* @throws MissingObjectException
+ * if an object is missing
* @throws IncorrectObjectTypeException
+ * if an object has an unexpected type
* @throws IOException
+ * if an IO error occurred
*/
TopoSortGenerator(Generator s) throws MissingObjectException,
IncorrectObjectTypeException, IOException {
@@ -47,7 +50,7 @@ class TopoSortGenerator extends Generator {
if (c == null) {
break;
}
- for (RevCommit p : c.parents) {
+ for (RevCommit p : c.getParents()) {
p.inDegree++;
if (firstParent) {
break;
@@ -86,7 +89,7 @@ class TopoSortGenerator extends Generator {
// All of our children have already produced,
// so it is OK for us to produce now as well.
//
- for (RevCommit p : c.parents) {
+ for (RevCommit p : c.getParents()) {
if (--p.inDegree == 0 && (p.flags & TOPO_DELAY) != 0) {
// This parent tried to come before us, but we are
// his last child. unpop the parent so it goes right
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/TreeRevFilter.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/TreeRevFilter.java
index 28a16f13d0..99943b78e6 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/TreeRevFilter.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/TreeRevFilter.java
@@ -12,7 +12,10 @@ package org.eclipse.jgit.revwalk;
import java.io.IOException;
import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import org.eclipse.jgit.internal.storage.commitgraph.ChangedPathFilter;
import org.eclipse.jgit.diff.DiffConfig;
import org.eclipse.jgit.diff.DiffEntry;
import org.eclipse.jgit.diff.DiffEntry.ChangeType;
@@ -41,9 +44,18 @@ public class TreeRevFilter extends RevFilter {
private static final int UNINTERESTING = RevWalk.UNINTERESTING;
+ private static final int FILTER_APPLIED = RevWalk.TREE_REV_FILTER_APPLIED;
+
private final int rewriteFlag;
+
private final TreeWalk pathFilter;
+ private long changedPathFilterTruePositive = 0;
+
+ private long changedPathFilterFalsePositive = 0;
+
+ private long changedPathFilterNegative = 0;
+
/**
* Create a {@link org.eclipse.jgit.revwalk.filter.RevFilter} from a
* {@link org.eclipse.jgit.treewalk.filter.TreeFilter}.
@@ -60,10 +72,9 @@ public class TreeRevFilter extends RevFilter {
this(walker, t, 0);
}
-
/**
- * Create a filter for the first phase of a parent-rewriting limited revision
- * walk.
+ * Create a filter for the first phase of a parent-rewriting limited
+ * revision walk.
* <p>
* This filter is ANDed to evaluate before all other filters and ties the
* configured {@link TreeFilter} into the revision walking process.
@@ -77,8 +88,8 @@ public class TreeRevFilter extends RevFilter {
* @param walker
* walker used for reading trees.
* @param t
- * filter to compare against any changed paths in each commit. If a
- * {@link FollowFilter}, will be replaced with a new filter
+ * filter to compare against any changed paths in each commit. If
+ * a {@link FollowFilter}, will be replaced with a new filter
* following new paths after a rename.
* @param rewriteFlag
* flag to color commits to be removed from the simplified DAT.
@@ -90,25 +101,24 @@ public class TreeRevFilter extends RevFilter {
this.rewriteFlag = rewriteFlag;
}
- /** {@inheritDoc} */
@Override
public RevFilter clone() {
throw new UnsupportedOperationException();
}
- /** {@inheritDoc} */
@Override
public boolean include(RevWalk walker, RevCommit c)
throws StopWalkException, MissingObjectException,
IncorrectObjectTypeException, IOException {
+ c.flags |= FILTER_APPLIED;
// Reset the tree filter to scan this commit and parents.
//
- RevCommit[] pList = c.parents;
+ RevCommit[] pList = c.getParents();
int nParents = pList.length;
TreeWalk tw = pathFilter;
ObjectId[] trees = new ObjectId[nParents + 1];
for (int i = 0; i < nParents; i++) {
- RevCommit p = c.parents[i];
+ RevCommit p = c.getParent(i);
if ((p.flags & PARSED) == 0) {
p.parseHeaders(walker);
}
@@ -121,12 +131,38 @@ public class TreeRevFilter extends RevFilter {
// We have exactly one parent. This is a very common case.
//
int chgs = 0, adds = 0;
- while (tw.next()) {
- chgs++;
- if (tw.getRawMode(0) == 0 && tw.getRawMode(1) != 0) {
- adds++;
- } else {
- break; // no point in looking at this further.
+ boolean changedPathFilterUsed = false;
+ boolean mustCalculateChgs = true;
+ ChangedPathFilter cpf = c.getChangedPathFilter(walker);
+ if (cpf != null) {
+ Optional<Set<byte[]>> paths = pathFilter.getFilter()
+ .getPathsBestEffort();
+ if (paths.isPresent()) {
+ changedPathFilterUsed = true;
+ if (paths.get().stream().noneMatch(cpf::maybeContains)) {
+ mustCalculateChgs = false;
+ }
+ }
+ }
+ if (mustCalculateChgs) {
+ while (tw.next()) {
+ chgs++;
+ if (tw.getRawMode(0) == 0 && tw.getRawMode(1) != 0) {
+ adds++;
+ } else {
+ break; // no point in looking at this further.
+ }
+ }
+ if (changedPathFilterUsed) {
+ if (chgs > 0) {
+ changedPathFilterTruePositive++;
+ } else {
+ changedPathFilterFalsePositive++;
+ }
+ }
+ } else {
+ if (changedPathFilterUsed) {
+ changedPathFilterNegative++;
}
}
@@ -146,7 +182,8 @@ public class TreeRevFilter extends RevFilter {
// commit. We need to update our filter to its older
// name, if we can discover it. Find out what that is.
//
- updateFollowFilter(trees, ((FollowFilter) tw.getFilter()).cfg);
+ updateFollowFilter(trees, ((FollowFilter) tw.getFilter()).cfg,
+ c);
}
return true;
} else if (nParents == 0) {
@@ -205,16 +242,18 @@ public class TreeRevFilter extends RevFilter {
return false;
}
- // Comment out below as this assumption is incorrect
if (chgs[i] == adds[i]) {
// All of the differences from this parent were because we
// added files that they did not have. This parent is our
// "empty tree root" and thus their history is not relevant.
// Cut our grandparents to be an empty list.
//
- pList[i].parents = RevCommit.NO_PARENTS;
+ tw.reset(pList[i].getTree());
+ if (!tw.next()) {
+ pList[i].parents = RevCommit.NO_PARENTS;
+ }
}
-
+
// We have an interesting difference relative to this parent.
//
diff = true;
@@ -236,13 +275,47 @@ public class TreeRevFilter extends RevFilter {
return false;
}
- /** {@inheritDoc} */
@Override
public boolean requiresCommitBody() {
return false;
}
- private void updateFollowFilter(ObjectId[] trees, DiffConfig cfg)
+ /**
+ * Return how many times a changed path filter correctly predicted that a
+ * path was changed in a commit, for statistics gathering purposes.
+ *
+ * @return count of true positives
+ * @since 6.7
+ */
+ public long getChangedPathFilterTruePositive() {
+ return changedPathFilterTruePositive;
+ }
+
+ /**
+ * Return how many times a changed path filter wrongly predicted that a path
+ * was changed in a commit, for statistics gathering purposes.
+ *
+ * @return count of false positives
+ * @since 6.7
+ */
+ public long getChangedPathFilterFalsePositive() {
+ return changedPathFilterFalsePositive;
+ }
+
+ /**
+ * Return how many times a changed path filter predicted that a path was not
+ * changed in a commit (allowing that commit to be skipped), for statistics
+ * gathering purposes.
+ *
+ * @return count of negatives
+ * @since 6.7
+ */
+ public long getChangedPathFilterNegative() {
+ return changedPathFilterNegative;
+ }
+
+ private void updateFollowFilter(ObjectId[] trees, DiffConfig cfg,
+ RevCommit commit)
throws MissingObjectException, IncorrectObjectTypeException,
CorruptObjectException, IOException {
TreeWalk tw = pathFilter;
@@ -261,7 +334,7 @@ public class TreeRevFilter extends RevFilter {
newFilter = FollowFilter.create(ent.getOldPath(), cfg);
RenameCallback callback = oldFilter.getRenameCallback();
if (callback != null) {
- callback.renamed(ent);
+ callback.renamed(ent, commit);
// forward the callback to the new follow filter
((FollowFilter) newFilter).setRenameCallback(callback);
}
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/CommitTimeRevFilter.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/CommitTimeRevFilter.java
index 13b7658c8e..7d113bec2e 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/CommitTimeRevFilter.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/CommitTimeRevFilter.java
@@ -98,13 +98,11 @@ public abstract class CommitTimeRevFilter extends RevFilter {
when = (int) (ts / 1000);
}
- /** {@inheritDoc} */
@Override
public RevFilter clone() {
return this;
}
- /** {@inheritDoc} */
@Override
public boolean requiresCommitBody() {
return false;
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/MaxCountRevFilter.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/MaxCountRevFilter.java
index 0e3a803b64..09bcb33f2e 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/MaxCountRevFilter.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/MaxCountRevFilter.java
@@ -46,7 +46,6 @@ public class MaxCountRevFilter extends RevFilter {
this.maxCount = maxCount;
}
- /** {@inheritDoc} */
@Override
public boolean include(RevWalk walker, RevCommit cmit)
throws StopWalkException, MissingObjectException,
@@ -57,7 +56,6 @@ public class MaxCountRevFilter extends RevFilter {
return true;
}
- /** {@inheritDoc} */
@Override
public RevFilter clone() {
return new MaxCountRevFilter(maxCount);
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/NotRevFilter.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/NotRevFilter.java
index 1482c51291..8fcebc9fa1 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/NotRevFilter.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/NotRevFilter.java
@@ -38,13 +38,11 @@ public class NotRevFilter extends RevFilter {
a = one;
}
- /** {@inheritDoc} */
@Override
public RevFilter negate() {
return a;
}
- /** {@inheritDoc} */
@Override
public boolean include(RevWalk walker, RevCommit c)
throws MissingObjectException, IncorrectObjectTypeException,
@@ -52,19 +50,16 @@ public class NotRevFilter extends RevFilter {
return !a.include(walker, c);
}
- /** {@inheritDoc} */
@Override
public boolean requiresCommitBody() {
return a.requiresCommitBody();
}
- /** {@inheritDoc} */
@Override
public RevFilter clone() {
return new NotRevFilter(a.clone());
}
- /** {@inheritDoc} */
@Override
public String toString() {
return "NOT " + a.toString(); //$NON-NLS-1$
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/RevFilter.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/RevFilter.java
index 256e4794cd..8430646305 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/RevFilter.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/RevFilter.java
@@ -264,7 +264,6 @@ public abstract class RevFilter {
@Override
public abstract RevFilter clone();
- /** {@inheritDoc} */
@Override
public String toString() {
String n = getClass().getName();
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/RevFlagFilter.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/RevFlagFilter.java
index 16d9f76143..f9ee632b50 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/RevFlagFilter.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/RevFlagFilter.java
@@ -91,13 +91,11 @@ public abstract class RevFlagFilter extends RevFilter {
flags = m;
}
- /** {@inheritDoc} */
@Override
public RevFilter clone() {
return this;
}
- /** {@inheritDoc} */
@Override
public String toString() {
return super.toString() + flags;
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/SkipRevFilter.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/SkipRevFilter.java
index 84df36a2d2..bf93b7ba3e 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/SkipRevFilter.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/SkipRevFilter.java
@@ -45,7 +45,6 @@ public class SkipRevFilter extends RevFilter {
this.skip = skip;
}
- /** {@inheritDoc} */
@Override
public boolean include(RevWalk walker, RevCommit cmit)
throws StopWalkException, MissingObjectException,
@@ -55,7 +54,6 @@ public class SkipRevFilter extends RevFilter {
return true;
}
- /** {@inheritDoc} */
@Override
public RevFilter clone() {
return new SkipRevFilter(skip);
diff --git a/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/SubStringRevFilter.java b/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/SubStringRevFilter.java
index 5fc9b76f79..296f3f50b4 100644
--- a/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/SubStringRevFilter.java
+++ b/server-core/src/main/java/org/eclipse/jgit/revwalk/filter/SubStringRevFilter.java
@@ -67,7 +67,6 @@ public abstract class SubStringRevFilter extends RevFilter {
pattern = new RawSubStringPattern(patternText);
}
- /** {@inheritDoc} */
@Override
public boolean include(RevWalk walker, RevCommit cmit)
throws MissingObjectException, IncorrectObjectTypeException,
@@ -75,7 +74,6 @@ public abstract class SubStringRevFilter extends RevFilter {
return pattern.match(text(cmit)) >= 0;
}
- /** {@inheritDoc} */
@Override
public boolean requiresCommitBody() {
return true;
@@ -90,13 +88,11 @@ public abstract class SubStringRevFilter extends RevFilter {
*/
protected abstract RawCharSequence text(RevCommit cmit);
- /** {@inheritDoc} */
@Override
public RevFilter clone() {
return this; // Typically we are actually thread-safe.
}
- /** {@inheritDoc} */
@Override
public String toString() {
return super.toString() + "(\"" + pattern.pattern() + "\")";
diff --git a/server-ee b/server-ee
index 18d6fa1077..2cc856a8b2 160000
--- a/server-ee
+++ b/server-ee
@@ -1 +1 @@
-Subproject commit 18d6fa107743816240657571e4bd11e9733f765b
+Subproject commit 2cc856a8b2db2970a64d4bad0b2a643d32a46072
diff --git a/server-plugin/pom.xml b/server-plugin/pom.xml
index 3935d1b72b..c8ddc0a8ac 100644
--- a/server-plugin/pom.xml
+++ b/server-plugin/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-archetype/pom.xml b/server-plugin/server-plugin-archetype/pom.xml
index c0b8eed5d1..2626e8e297 100644
--- a/server-plugin/server-plugin-archetype/pom.xml
+++ b/server-plugin/server-plugin-archetype/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<build>
<resources>
diff --git a/server-plugin/server-plugin-authenticator-ldap/pom.xml b/server-plugin/server-plugin-authenticator-ldap/pom.xml
index 47d881d370..e2f29d0d88 100644
--- a/server-plugin/server-plugin-authenticator-ldap/pom.xml
+++ b/server-plugin/server-plugin-authenticator-ldap/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.authenticator.ldap.LdapModule</moduleClass>
diff --git a/server-plugin/server-plugin-buildspec-bazel/pom.xml b/server-plugin/server-plugin-buildspec-bazel/pom.xml
index 7ed83beb8a..778a201632 100644
--- a/server-plugin/server-plugin-buildspec-bazel/pom.xml
+++ b/server-plugin/server-plugin-buildspec-bazel/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.buildspec.bazel.BazelModule</moduleClass>
diff --git a/server-plugin/server-plugin-buildspec-cmake/pom.xml b/server-plugin/server-plugin-buildspec-cmake/pom.xml
index c3b7e65570..1fe7928702 100644
--- a/server-plugin/server-plugin-buildspec-cmake/pom.xml
+++ b/server-plugin/server-plugin-buildspec-cmake/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-buildspec-dotnet/pom.xml b/server-plugin/server-plugin-buildspec-dotnet/pom.xml
index 15606fdec1..d9707e80d4 100644
--- a/server-plugin/server-plugin-buildspec-dotnet/pom.xml
+++ b/server-plugin/server-plugin-buildspec-dotnet/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-buildspec-golang/pom.xml b/server-plugin/server-plugin-buildspec-golang/pom.xml
index a22856ab69..0f6ad2b3d0 100644
--- a/server-plugin/server-plugin-buildspec-golang/pom.xml
+++ b/server-plugin/server-plugin-buildspec-golang/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-buildspec-gradle/pom.xml b/server-plugin/server-plugin-buildspec-gradle/pom.xml
index b32d047ec9..fc49fa6705 100644
--- a/server-plugin/server-plugin-buildspec-gradle/pom.xml
+++ b/server-plugin/server-plugin-buildspec-gradle/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-buildspec-maven/pom.xml b/server-plugin/server-plugin-buildspec-maven/pom.xml
index a27dada04f..947bfcebf5 100644
--- a/server-plugin/server-plugin-buildspec-maven/pom.xml
+++ b/server-plugin/server-plugin-buildspec-maven/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-buildspec-node/pom.xml b/server-plugin/server-plugin-buildspec-node/pom.xml
index bc8ee3d441..1124cf3364 100644
--- a/server-plugin/server-plugin-buildspec-node/pom.xml
+++ b/server-plugin/server-plugin-buildspec-node/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.buildspec.node.NodePluginModule</moduleClass>
diff --git a/server-plugin/server-plugin-buildspec-python/pom.xml b/server-plugin/server-plugin-buildspec-python/pom.xml
index d57946b16f..ab08867de7 100644
--- a/server-plugin/server-plugin-buildspec-python/pom.xml
+++ b/server-plugin/server-plugin-buildspec-python/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-buildspec-rust/pom.xml b/server-plugin/server-plugin-buildspec-rust/pom.xml
index ba26082912..74e5f6be6e 100644
--- a/server-plugin/server-plugin-buildspec-rust/pom.xml
+++ b/server-plugin/server-plugin-buildspec-rust/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-executor-kubernetes/pom.xml b/server-plugin/server-plugin-executor-kubernetes/pom.xml
index da18633bb4..dcc9749726 100644
--- a/server-plugin/server-plugin-executor-kubernetes/pom.xml
+++ b/server-plugin/server-plugin-executor-kubernetes/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.executor.kubernetes.KubernetesModule</moduleClass>
diff --git a/server-plugin/server-plugin-executor-remotedocker/pom.xml b/server-plugin/server-plugin-executor-remotedocker/pom.xml
index 6b4ab308c3..8c400060cf 100644
--- a/server-plugin/server-plugin-executor-remotedocker/pom.xml
+++ b/server-plugin/server-plugin-executor-remotedocker/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-executor-remoteshell/pom.xml b/server-plugin/server-plugin-executor-remoteshell/pom.xml
index 1b0222481e..f36a23f535 100644
--- a/server-plugin/server-plugin-executor-remoteshell/pom.xml
+++ b/server-plugin/server-plugin-executor-remoteshell/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-executor-serverdocker/pom.xml b/server-plugin/server-plugin-executor-serverdocker/pom.xml
index f6cb8ac434..c50f4d6633 100644
--- a/server-plugin/server-plugin-executor-serverdocker/pom.xml
+++ b/server-plugin/server-plugin-executor-serverdocker/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.executor.serverdocker.ServerDockerModule</moduleClass>
diff --git a/server-plugin/server-plugin-executor-servershell/pom.xml b/server-plugin/server-plugin-executor-servershell/pom.xml
index 46b16c8b8b..e8dde55706 100644
--- a/server-plugin/server-plugin-executor-servershell/pom.xml
+++ b/server-plugin/server-plugin-executor-servershell/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.executor.servershell.ServerShellModule</moduleClass>
diff --git a/server-plugin/server-plugin-import-bitbucketcloud/pom.xml b/server-plugin/server-plugin-import-bitbucketcloud/pom.xml
index 43d9626a78..6bf6eefa1b 100644
--- a/server-plugin/server-plugin-import-bitbucketcloud/pom.xml
+++ b/server-plugin/server-plugin-import-bitbucketcloud/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.imports.bitbucketcloud.BitbucketModule</moduleClass>
diff --git a/server-plugin/server-plugin-import-gitea/pom.xml b/server-plugin/server-plugin-import-gitea/pom.xml
index 3593393b9f..3d67712123 100644
--- a/server-plugin/server-plugin-import-gitea/pom.xml
+++ b/server-plugin/server-plugin-import-gitea/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.imports.gitea.GiteaModule</moduleClass>
diff --git a/server-plugin/server-plugin-import-github/pom.xml b/server-plugin/server-plugin-import-github/pom.xml
index 135540fc8f..4e3c600fde 100644
--- a/server-plugin/server-plugin-import-github/pom.xml
+++ b/server-plugin/server-plugin-import-github/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.imports.github.GitHubModule</moduleClass>
diff --git a/server-plugin/server-plugin-import-gitlab/pom.xml b/server-plugin/server-plugin-import-gitlab/pom.xml
index 5d708cbba3..d58d324d73 100644
--- a/server-plugin/server-plugin-import-gitlab/pom.xml
+++ b/server-plugin/server-plugin-import-gitlab/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.imports.gitlab.GitLabModule</moduleClass>
diff --git a/server-plugin/server-plugin-import-jiracloud/pom.xml b/server-plugin/server-plugin-import-jiracloud/pom.xml
index 5a81394a7f..dab0247cae 100644
--- a/server-plugin/server-plugin-import-jiracloud/pom.xml
+++ b/server-plugin/server-plugin-import-jiracloud/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.imports.jiracloud.JiraModule</moduleClass>
diff --git a/server-plugin/server-plugin-import-url/pom.xml b/server-plugin/server-plugin-import-url/pom.xml
index 7243823ecb..c887ff4c9a 100644
--- a/server-plugin/server-plugin-import-url/pom.xml
+++ b/server-plugin/server-plugin-import-url/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.imports.url.UrlModule</moduleClass>
diff --git a/server-plugin/server-plugin-import-youtrack/pom.xml b/server-plugin/server-plugin-import-youtrack/pom.xml
index 51d15e6f75..e46ddfcf01 100644
--- a/server-plugin/server-plugin-import-youtrack/pom.xml
+++ b/server-plugin/server-plugin-import-youtrack/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.imports.youtrack.YouTrackModule</moduleClass>
diff --git a/server-plugin/server-plugin-mail-gmail/pom.xml b/server-plugin/server-plugin-mail-gmail/pom.xml
index 27267409a3..d54ca9a18f 100644
--- a/server-plugin/server-plugin-mail-gmail/pom.xml
+++ b/server-plugin/server-plugin-mail-gmail/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.mail.gmail.GmailModule</moduleClass>
diff --git a/server-plugin/server-plugin-mail-office365/pom.xml b/server-plugin/server-plugin-mail-office365/pom.xml
index 4b2350b2fa..503a2a17bf 100644
--- a/server-plugin/server-plugin-mail-office365/pom.xml
+++ b/server-plugin/server-plugin-mail-office365/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.mail.office365.Office365Module</moduleClass>
diff --git a/server-plugin/server-plugin-mail-smtpimap/pom.xml b/server-plugin/server-plugin-mail-smtpimap/pom.xml
index fd349886b8..1cf8a3bbf0 100644
--- a/server-plugin/server-plugin-mail-smtpimap/pom.xml
+++ b/server-plugin/server-plugin-mail-smtpimap/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.mail.smtpimap.SmtpImapModule</moduleClass>
diff --git a/server-plugin/server-plugin-notification-discord/pom.xml b/server-plugin/server-plugin-notification-discord/pom.xml
index aa097f734d..77a7a59aa5 100644
--- a/server-plugin/server-plugin-notification-discord/pom.xml
+++ b/server-plugin/server-plugin-notification-discord/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.notification.discord.DiscordModule</moduleClass>
diff --git a/server-plugin/server-plugin-notification-ntfy/pom.xml b/server-plugin/server-plugin-notification-ntfy/pom.xml
index fa52b6c9bf..d80d2416ba 100644
--- a/server-plugin/server-plugin-notification-ntfy/pom.xml
+++ b/server-plugin/server-plugin-notification-ntfy/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.notification.ntfy.NtfyModule</moduleClass>
diff --git a/server-plugin/server-plugin-notification-slack/pom.xml b/server-plugin/server-plugin-notification-slack/pom.xml
index afc3fb3913..3198668ff7 100644
--- a/server-plugin/server-plugin-notification-slack/pom.xml
+++ b/server-plugin/server-plugin-notification-slack/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.notification.slack.SlackModule</moduleClass>
diff --git a/server-plugin/server-plugin-pack-container/pom.xml b/server-plugin/server-plugin-pack-container/pom.xml
index 4fe3e34f20..3dbe5fad3a 100644
--- a/server-plugin/server-plugin-pack-container/pom.xml
+++ b/server-plugin/server-plugin-pack-container/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-pack-gem/pom.xml b/server-plugin/server-plugin-pack-gem/pom.xml
index 39704546a9..d15fea3d45 100644
--- a/server-plugin/server-plugin-pack-gem/pom.xml
+++ b/server-plugin/server-plugin-pack-gem/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-pack-helm/pom.xml b/server-plugin/server-plugin-pack-helm/pom.xml
index 80ed24f211..d4bfbda015 100644
--- a/server-plugin/server-plugin-pack-helm/pom.xml
+++ b/server-plugin/server-plugin-pack-helm/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-pack-maven/pom.xml b/server-plugin/server-plugin-pack-maven/pom.xml
index 1fbeba2932..d0848864c4 100644
--- a/server-plugin/server-plugin-pack-maven/pom.xml
+++ b/server-plugin/server-plugin-pack-maven/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-pack-npm/pom.xml b/server-plugin/server-plugin-pack-npm/pom.xml
index 6d7b730bfa..5ac323e399 100644
--- a/server-plugin/server-plugin-pack-npm/pom.xml
+++ b/server-plugin/server-plugin-pack-npm/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-pack-nuget/pom.xml b/server-plugin/server-plugin-pack-nuget/pom.xml
index 547bd70510..fcb7b5182b 100644
--- a/server-plugin/server-plugin-pack-nuget/pom.xml
+++ b/server-plugin/server-plugin-pack-nuget/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-pack-pypi/pom.xml b/server-plugin/server-plugin-pack-pypi/pom.xml
index 8b0017913f..1d6a1b2ea8 100644
--- a/server-plugin/server-plugin-pack-pypi/pom.xml
+++ b/server-plugin/server-plugin-pack-pypi/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-report-checkstyle/pom.xml b/server-plugin/server-plugin-report-checkstyle/pom.xml
index b0ec47d208..f39d938090 100644
--- a/server-plugin/server-plugin-report-checkstyle/pom.xml
+++ b/server-plugin/server-plugin-report-checkstyle/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-report-clippy/pom.xml b/server-plugin/server-plugin-report-clippy/pom.xml
index a67a411150..e35e7b29d9 100644
--- a/server-plugin/server-plugin-report-clippy/pom.xml
+++ b/server-plugin/server-plugin-report-clippy/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-report-clover/pom.xml b/server-plugin/server-plugin-report-clover/pom.xml
index 4da43ba585..bd5b030294 100644
--- a/server-plugin/server-plugin-report-clover/pom.xml
+++ b/server-plugin/server-plugin-report-clover/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-report-cobertura/pom.xml b/server-plugin/server-plugin-report-cobertura/pom.xml
index 472a512a29..460a9b2e22 100644
--- a/server-plugin/server-plugin-report-cobertura/pom.xml
+++ b/server-plugin/server-plugin-report-cobertura/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-report-coverage/pom.xml b/server-plugin/server-plugin-report-coverage/pom.xml
index 652a2ca26a..3aea900985 100644
--- a/server-plugin/server-plugin-report-coverage/pom.xml
+++ b/server-plugin/server-plugin-report-coverage/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.report.coverage.CoverageModule</moduleClass>
diff --git a/server-plugin/server-plugin-report-cpd/pom.xml b/server-plugin/server-plugin-report-cpd/pom.xml
index 3705a6abc5..5be172bdf1 100644
--- a/server-plugin/server-plugin-report-cpd/pom.xml
+++ b/server-plugin/server-plugin-report-cpd/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-report-cppcheck/pom.xml b/server-plugin/server-plugin-report-cppcheck/pom.xml
index a3addfba7d..2237818ec3 100644
--- a/server-plugin/server-plugin-report-cppcheck/pom.xml
+++ b/server-plugin/server-plugin-report-cppcheck/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-report-gtest/pom.xml b/server-plugin/server-plugin-report-gtest/pom.xml
index 014fa84f4e..cf4b44a315 100644
--- a/server-plugin/server-plugin-report-gtest/pom.xml
+++ b/server-plugin/server-plugin-report-gtest/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-report-html/pom.xml b/server-plugin/server-plugin-report-html/pom.xml
index e597905e72..eed111fc95 100644
--- a/server-plugin/server-plugin-report-html/pom.xml
+++ b/server-plugin/server-plugin-report-html/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.report.html.HtmlModule</moduleClass>
diff --git a/server-plugin/server-plugin-report-jacoco/pom.xml b/server-plugin/server-plugin-report-jacoco/pom.xml
index ff54de4c02..d12fa61de7 100644
--- a/server-plugin/server-plugin-report-jacoco/pom.xml
+++ b/server-plugin/server-plugin-report-jacoco/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-report-jest/pom.xml b/server-plugin/server-plugin-report-jest/pom.xml
index dc054116f8..8f42b8653f 100644
--- a/server-plugin/server-plugin-report-jest/pom.xml
+++ b/server-plugin/server-plugin-report-jest/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-report-junit/pom.xml b/server-plugin/server-plugin-report-junit/pom.xml
index f7b7b73a6a..f81fa032eb 100644
--- a/server-plugin/server-plugin-report-junit/pom.xml
+++ b/server-plugin/server-plugin-report-junit/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-report-markdown/pom.xml b/server-plugin/server-plugin-report-markdown/pom.xml
index f6c8df979f..750b121722 100644
--- a/server-plugin/server-plugin-report-markdown/pom.xml
+++ b/server-plugin/server-plugin-report-markdown/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.report.markdown.MarkdownModule</moduleClass>
diff --git a/server-plugin/server-plugin-report-mypy/pom.xml b/server-plugin/server-plugin-report-mypy/pom.xml
index 67b8bc9b5a..46ab4c082d 100644
--- a/server-plugin/server-plugin-report-mypy/pom.xml
+++ b/server-plugin/server-plugin-report-mypy/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-report-pmd/pom.xml b/server-plugin/server-plugin-report-pmd/pom.xml
index 3595bdcbb0..cffa4e38b0 100644
--- a/server-plugin/server-plugin-report-pmd/pom.xml
+++ b/server-plugin/server-plugin-report-pmd/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-report-problem/pom.xml b/server-plugin/server-plugin-report-problem/pom.xml
index 54f75abdc2..35157d765c 100644
--- a/server-plugin/server-plugin-report-problem/pom.xml
+++ b/server-plugin/server-plugin-report-problem/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.report.problem.ProblemModule</moduleClass>
diff --git a/server-plugin/server-plugin-report-pylint/pom.xml b/server-plugin/server-plugin-report-pylint/pom.xml
index 7f29a5414a..65679642f2 100644
--- a/server-plugin/server-plugin-report-pylint/pom.xml
+++ b/server-plugin/server-plugin-report-pylint/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-report-roslynator/pom.xml b/server-plugin/server-plugin-report-roslynator/pom.xml
index a5ea2f5009..ddbe2e64c3 100644
--- a/server-plugin/server-plugin-report-roslynator/pom.xml
+++ b/server-plugin/server-plugin-report-roslynator/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-report-ruff/pom.xml b/server-plugin/server-plugin-report-ruff/pom.xml
index 734c86638f..c3be76bfe5 100644
--- a/server-plugin/server-plugin-report-ruff/pom.xml
+++ b/server-plugin/server-plugin-report-ruff/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-report-spotbugs/pom.xml b/server-plugin/server-plugin-report-spotbugs/pom.xml
index 314357aff2..0199fba2c4 100644
--- a/server-plugin/server-plugin-report-spotbugs/pom.xml
+++ b/server-plugin/server-plugin-report-spotbugs/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-report-trx/pom.xml b/server-plugin/server-plugin-report-trx/pom.xml
index 8e106a8466..9b5a92a52e 100644
--- a/server-plugin/server-plugin-report-trx/pom.xml
+++ b/server-plugin/server-plugin-report-trx/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>
diff --git a/server-plugin/server-plugin-report-unittest/pom.xml b/server-plugin/server-plugin-report-unittest/pom.xml
index da1cfd01fc..d13f1c4152 100644
--- a/server-plugin/server-plugin-report-unittest/pom.xml
+++ b/server-plugin/server-plugin-report-unittest/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.report.unittest.UnitTestModule</moduleClass>
diff --git a/server-plugin/server-plugin-sso-discord/pom.xml b/server-plugin/server-plugin-sso-discord/pom.xml
index bd8120ba20..3d331531b6 100644
--- a/server-plugin/server-plugin-sso-discord/pom.xml
+++ b/server-plugin/server-plugin-sso-discord/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.sso.discord.DiscordModule</moduleClass>
diff --git a/server-plugin/server-plugin-sso-openid/pom.xml b/server-plugin/server-plugin-sso-openid/pom.xml
index 79c077ee78..501e09c8e4 100644
--- a/server-plugin/server-plugin-sso-openid/pom.xml
+++ b/server-plugin/server-plugin-sso-openid/pom.xml
@@ -6,7 +6,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server-plugin</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<properties>
<moduleClass>io.onedev.server.plugin.sso.openid.OpenIdModule</moduleClass>
diff --git a/server-product/pom.xml b/server-product/pom.xml
index 165124ad6e..cdfb7f6029 100644
--- a/server-product/pom.xml
+++ b/server-product/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>io.onedev</groupId>
<artifactId>server</artifactId>
- <version>13.1.4</version>
+ <version>13.1.6</version>
</parent>
<dependencies>
<dependency>