Skip to content

Commit

Permalink
Merge pull request #1416 from scm-manager/feature/hg_hooks_over_tcp
Browse files Browse the repository at this point in the history
Feature/hg hooks over tcp
  • Loading branch information
pfeuffer committed Nov 27, 2020
2 parents 5f130c6 + d732100 commit 4e326fe
Show file tree
Hide file tree
Showing 75 changed files with 2,606 additions and 2,986 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Added
- Add tooltips to short links on repository overview ([#1441](https://github.com/scm-manager/scm-manager/pull/1441))
- Show the date of the last commit for branches in the frontend ([#1439](https://github.com/scm-manager/scm-manager/pull/1439))
- Unify and add description to key view across user settings ([#1440](https://github.com/scm-manager/scm-manager/pull/1440))

### Changed
- Send mercurial hook callbacks over separate tcp socket instead of http ([#1416](https://github.com/scm-manager/scm-manager/pull/1416))

### Fixed
- Language detection of files with interpreter parameters e.g.: `#!/usr/bin/make -f` ([#1450](https://github.com/scm-manager/scm-manager/issues/1450))

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@
<!-- xml -->

<dependency>
<groupId>jakarta.xml.bind</groupId>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>${jaxb.version}</version>
</dependency>
Expand Down
6 changes: 6 additions & 0 deletions scm-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
71 changes: 71 additions & 0 deletions scm-core/src/main/java/sonia/scm/TransactionId.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* MIT License
*
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package sonia.scm;

import com.google.common.annotations.VisibleForTesting;
import org.slf4j.MDC;

import java.util.Optional;

/**
* Id of the current transaction.
* The transaction id is mainly used for logging and debugging.
*
* @since 2.10.0
*/
public final class TransactionId {

@VisibleForTesting
public static final String KEY = "transaction_id";

private TransactionId() {
}

/**
* Binds the given transaction id to the current thread.
*
* @param transactionId transaction id
*/
public static void set(String transactionId) {
MDC.put(KEY, transactionId);
}

/**
* Returns an optional transaction id.
* If there is no transaction id bound to the thread, the method will return an empty optional.
*
* @return optional transaction id
*/
public static Optional<String> get() {
return Optional.ofNullable(MDC.get(KEY));
}

/**
* Removes a bound transaction id from the current thread.
*/
public static void clear() {
MDC.remove(KEY);
}
}
42 changes: 42 additions & 0 deletions scm-core/src/test/java/sonia/scm/TransactionIdTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* MIT License
*
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package sonia.scm;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

class TransactionIdTest {

@Test
void shouldSetGetAndClear() {
TransactionId.set("42");

assertThat(TransactionId.get()).contains("42");
TransactionId.clear();
assertThat(TransactionId.get()).isEmpty();
}

}
14 changes: 14 additions & 0 deletions scm-plugins/scm-hg-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,23 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@
import lombok.NoArgsConstructor;
import lombok.Setter;

@NoArgsConstructor
@Getter
@Setter
@NoArgsConstructor
@SuppressWarnings("java:S2160") // we don't need equals for dto
public class HgConfigDto extends HalRepresentation implements UpdateHgConfigDto {


private boolean disabled;

private String encoding;
Expand All @@ -44,7 +46,6 @@ public class HgConfigDto extends HalRepresentation implements UpdateHgConfigDto
private boolean useOptimizedBytecode;
private boolean showRevisionInId;
private boolean enableHttpPostArgs;
private boolean disableHookSSLValidation;

@Override
@SuppressWarnings("squid:S1185") // We want to have this method available in this package
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,5 @@ interface UpdateHgConfigDto {

boolean isShowRevisionInId();

boolean isDisableHookSSLValidation();

boolean isEnableHttpPostArgs();
}

0 comments on commit 4e326fe

Please sign in to comment.