merge with default branch

This commit is contained in:
Sebastian Sdorra
2020-01-06 14:07:49 +01:00
28 changed files with 1607 additions and 1669 deletions

8
Jenkinsfile vendored
View File

@@ -55,7 +55,13 @@ node('docker') {
if (isMainBranch()) {
stage('Lifecycle') {
nexusPolicyEvaluation iqApplication: selectedApplication('scm'), iqScanPatterns: [[scanPattern: 'scm-server/target/scm-server-app.zip']], iqStage: 'build'
try {
// failBuildOnNetworkError -> so we can catch the exception and neither fail nor make our build unstable
nexusPolicyEvaluation iqApplication: selectedApplication('scm'), iqScanPatterns: [[scanPattern: 'scm-server/target/scm-server-app.zip']], iqStage: 'build', failBuildOnNetworkError: true
} catch (Exception e) {
echo "ERROR: iQ Server policy eval failed. Not marking build unstable for now."
echo "ERROR: iQ Server Exception: ${e.getMessage()}"
}
}
stage('Archive') {

View File

@@ -12,18 +12,25 @@ import static java.util.Collections.unmodifiableCollection;
* case you can use {@link #getFilesWithConflict()} to get a list of files with merge conflicts.
*/
public class MergeCommandResult {
private final Collection<String> filesWithConflict;
private final String newHeadRevision;
private final String targetRevision;
private final String revisionToMerge;
private MergeCommandResult(Collection<String> filesWithConflict) {
private MergeCommandResult(Collection<String> filesWithConflict, String targetRevision, String revisionToMerge, String newHeadRevision) {
this.filesWithConflict = filesWithConflict;
this.targetRevision = targetRevision;
this.revisionToMerge = revisionToMerge;
this.newHeadRevision = newHeadRevision;
}
public static MergeCommandResult success() {
return new MergeCommandResult(emptyList());
public static MergeCommandResult success(String targetRevision, String revisionToMerge, String newHeadRevision) {
return new MergeCommandResult(emptyList(), targetRevision, revisionToMerge, newHeadRevision);
}
public static MergeCommandResult failure(Collection<String> filesWithConflict) {
return new MergeCommandResult(new HashSet<>(filesWithConflict));
public static MergeCommandResult failure(String targetRevision, String revisionToMerge, Collection<String> filesWithConflict) {
return new MergeCommandResult(new HashSet<>(filesWithConflict), targetRevision, revisionToMerge, null);
}
/**
@@ -31,7 +38,7 @@ public class MergeCommandResult {
* merge conflicts. In this case you can use {@link #getFilesWithConflict()} to check what files could not be merged.
*/
public boolean isSuccess() {
return filesWithConflict.isEmpty();
return filesWithConflict.isEmpty() && newHeadRevision != null;
}
/**
@@ -41,4 +48,26 @@ public class MergeCommandResult {
public Collection<String> getFilesWithConflict() {
return unmodifiableCollection(filesWithConflict);
}
/**
* Returns the revision of the new head of the target branch, if the merge was successful ({@link #isSuccess()})
*/
public String getNewHeadRevision() {
return newHeadRevision;
}
/**
* Returns the revision of the target branch prior to the merge.
*/
public String getTargetRevision() {
return targetRevision;
}
/**
* Returns the revision of the branch that was merged into the target (or in case of a conflict of the revision that
* should have been merged).
*/
public String getRevisionToMerge() {
return revisionToMerge;
}
}

View File

@@ -7,6 +7,12 @@ import sonia.scm.repository.api.MergeStrategy;
import java.util.Set;
public interface MergeCommand {
/**
* Executes the merge.
* @param request The parameters specifying the merge.
* @return Result holding either the new revision or a list of conflicting files.
* @throws sonia.scm.NoChangesMadeException If the merge neither had a conflict nor made any change.
*/
MergeCommandResult merge(MergeCommandRequest request);
MergeDryRunCommandResult dryRun(MergeCommandRequest request);

View File

@@ -8,6 +8,14 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.UUID;
/**
* CopyOnWrite creates a copy of the target file, before it is modified. This should prevent empty or incomplete files
* on errors such as full disk.
*
* javasecurity:S2083: SonarQube thinks that the path (targetFile) is generated from an http header (HttpUtil), but
* this is not true. It looks like a false-positive, so we suppress the warning for now.
*/
@SuppressWarnings("javasecurity:S2083")
public final class CopyOnWrite {
private static final Logger LOG = LoggerFactory.getLogger(CopyOnWrite.class);

View File

@@ -186,6 +186,10 @@ class AbstractGitCommand
return context;
}
sonia.scm.repository.Repository getRepository() {
return repository;
}
void checkOutBranch(String branchName) throws IOException {
try {
clone.checkout().setName(branchName).call();

View File

@@ -2,6 +2,7 @@ package sonia.scm.repository.spi;
import com.google.common.base.Strings;
import org.eclipse.jgit.diff.DiffEntry;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -10,6 +11,8 @@ import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.treewalk.EmptyTreeIterator;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.jgit.treewalk.filter.PathFilter;
import sonia.scm.ContextEntry;
import sonia.scm.NotFoundException;
import sonia.scm.repository.GitUtil;
import sonia.scm.util.Util;
@@ -38,7 +41,15 @@ final class Differ implements AutoCloseable {
RevWalk walk = new RevWalk(repository);
ObjectId revision = repository.resolve(request.getRevision());
RevCommit commit = walk.parseCommit(revision);
if (revision == null) {
throw NotFoundException.notFound(ContextEntry.ContextBuilder.entity("revision not found", request.getRevision()));
}
RevCommit commit;
try {
commit = walk.parseCommit(revision);
} catch (MissingObjectException ex) {
throw NotFoundException.notFound(ContextEntry.ContextBuilder.entity("revision not found", request.getRevision()));
}
walk.markStart(commit);
commit = walk.next();
@@ -46,34 +57,25 @@ final class Differ implements AutoCloseable {
treeWalk.reset();
treeWalk.setRecursive(true);
if (Util.isNotEmpty(request.getPath()))
{
if (Util.isNotEmpty(request.getPath())) {
treeWalk.setFilter(PathFilter.create(request.getPath()));
}
if (!Strings.isNullOrEmpty(request.getAncestorChangeset()))
{
if (!Strings.isNullOrEmpty(request.getAncestorChangeset())) {
ObjectId otherRevision = repository.resolve(request.getAncestorChangeset());
ObjectId ancestorId = GitUtil.computeCommonAncestor(repository, revision, otherRevision);
RevTree tree = walk.parseCommit(ancestorId).getTree();
treeWalk.addTree(tree);
}
else if (commit.getParentCount() > 0)
{
} else if (commit.getParentCount() > 0) {
RevTree tree = commit.getParent(0).getTree();
if (tree != null)
{
if (tree != null) {
treeWalk.addTree(tree);
}
else
{
} else {
treeWalk.addTree(new EmptyTreeIterator());
}
}
else
{
} else {
treeWalk.addTree(new EmptyTreeIterator());
}

View File

@@ -7,6 +7,7 @@ import sonia.scm.repository.Repository;
import sonia.scm.repository.api.MergeCommandResult;
import java.io.IOException;
import java.util.Collections;
class GitFastForwardIfPossible extends GitMergeStrategy {
@@ -22,7 +23,7 @@ class GitFastForwardIfPossible extends GitMergeStrategy {
MergeResult fastForwardResult = mergeWithFastForwardOnlyMode();
if (fastForwardResult.getMergeStatus().isSuccessful()) {
push();
return MergeCommandResult.success();
return createSuccessResult(fastForwardResult.getNewHead().name());
} else {
return fallbackMerge.run();
}

View File

@@ -3,10 +3,16 @@ package sonia.scm.repository.spi;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.MergeCommand;
import org.eclipse.jgit.api.MergeResult;
import org.eclipse.jgit.revwalk.RevCommit;
import sonia.scm.NoChangesMadeException;
import sonia.scm.repository.Repository;
import sonia.scm.repository.api.MergeCommandResult;
import java.io.IOException;
import java.util.Collections;
import java.util.Optional;
import static sonia.scm.repository.spi.GitRevisionExtractor.extractRevisionFromRevCommit;
class GitMergeCommit extends GitMergeStrategy {
@@ -21,11 +27,12 @@ class GitMergeCommit extends GitMergeStrategy {
MergeResult result = doMergeInClone(mergeCommand);
if (result.getMergeStatus().isSuccessful()) {
doCommit();
RevCommit revCommit = doCommit().orElseThrow(() -> new NoChangesMadeException(getRepository()));
push();
return MergeCommandResult.success();
return createSuccessResult(extractRevisionFromRevCommit(revCommit));
} else {
return analyseFailure(result);
}
}
}

View File

@@ -6,6 +6,7 @@ import org.eclipse.jgit.api.MergeCommand;
import org.eclipse.jgit.api.MergeResult;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.repository.InternalRepositoryException;
@@ -14,6 +15,7 @@ import sonia.scm.repository.api.MergeCommandResult;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.Optional;
abstract class GitMergeStrategy extends AbstractGitCommand.GitCloneWorker<MergeCommandResult> {
@@ -24,37 +26,57 @@ abstract class GitMergeStrategy extends AbstractGitCommand.GitCloneWorker<MergeC
"",
"Automatic merge by SCM-Manager.");
private final String target;
private final String toMerge;
private final String targetBranch;
private final ObjectId targetRevision;
private final String branchToMerge;
private final ObjectId revisionToMerge;
private final Person author;
private final String messageTemplate;
GitMergeStrategy(Git clone, MergeCommandRequest request, GitContext context, sonia.scm.repository.Repository repository) {
super(clone, context, repository);
this.target = request.getTargetBranch();
this.toMerge = request.getBranchToMerge();
this.targetBranch = request.getTargetBranch();
this.branchToMerge = request.getBranchToMerge();
this.author = request.getAuthor();
this.messageTemplate = request.getMessageTemplate();
try {
this.targetRevision = resolveRevision(request.getTargetBranch());
this.revisionToMerge = resolveRevision(request.getBranchToMerge());
} catch (IOException e) {
throw new InternalRepositoryException(repository, "Could not resolve revisions of target branch or branch to merge", e);
}
}
MergeResult doMergeInClone(MergeCommand mergeCommand) throws IOException {
MergeResult result;
try {
ObjectId sourceRevision = resolveRevision(toMerge);
ObjectId sourceRevision = resolveRevision(branchToMerge);
mergeCommand
.setCommit(false) // we want to set the author manually
.include(toMerge, sourceRevision);
.include(branchToMerge, sourceRevision);
result = mergeCommand.call();
} catch (GitAPIException e) {
throw new InternalRepositoryException(getContext().getRepository(), "could not merge branch " + toMerge + " into " + target, e);
throw new InternalRepositoryException(getContext().getRepository(), "could not merge branch " + branchToMerge + " into " + targetBranch, e);
}
return result;
}
void doCommit() {
logger.debug("merged branch {} into {}", toMerge, target);
doCommit(MessageFormat.format(determineMessageTemplate(), toMerge, target), author);
Optional<RevCommit> doCommit() {
logger.debug("merged branch {} into {}", branchToMerge, targetBranch);
return doCommit(MessageFormat.format(determineMessageTemplate(), branchToMerge, targetBranch), author);
}
MergeCommandResult createSuccessResult(String newRevision) {
return MergeCommandResult.success(targetRevision.name(), revisionToMerge.name(), newRevision);
}
ObjectId getTargetRevision() {
return targetRevision;
}
ObjectId getRevisionToMerge() {
return revisionToMerge;
}
private String determineMessageTemplate() {
@@ -66,7 +88,7 @@ abstract class GitMergeStrategy extends AbstractGitCommand.GitCloneWorker<MergeC
}
MergeCommandResult analyseFailure(MergeResult result) {
logger.info("could not merge branch {} into {} due to conflict in paths {}", toMerge, target, result.getConflicts().keySet());
return MergeCommandResult.failure(result.getConflicts().keySet());
logger.info("could not merge branch {} into {} due to conflict in paths {}", branchToMerge, targetBranch, result.getConflicts().keySet());
return MergeCommandResult.failure(targetRevision.name(), revisionToMerge.name(), result.getConflicts().keySet());
}
}

View File

@@ -1,13 +1,17 @@
package sonia.scm.repository.spi;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.MergeCommand;
import org.eclipse.jgit.api.MergeResult;
import org.eclipse.jgit.revwalk.RevCommit;
import sonia.scm.NoChangesMadeException;
import sonia.scm.repository.Repository;
import sonia.scm.repository.api.MergeCommandResult;
import org.eclipse.jgit.api.MergeCommand;
import java.io.IOException;
import static sonia.scm.repository.spi.GitRevisionExtractor.extractRevisionFromRevCommit;
class GitMergeWithSquash extends GitMergeStrategy {
GitMergeWithSquash(Git clone, MergeCommandRequest request, GitContext context, Repository repository) {
@@ -21,9 +25,9 @@ class GitMergeWithSquash extends GitMergeStrategy {
MergeResult result = doMergeInClone(mergeCommand);
if (result.getMergeStatus().isSuccessful()) {
doCommit();
RevCommit revCommit = doCommit().orElseThrow(() -> new NoChangesMadeException(getRepository()));
push();
return MergeCommandResult.success();
return MergeCommandResult.success(getTargetRevision().name(), revCommit.name(), extractRevisionFromRevCommit(revCommit));
} else {
return analyseFailure(result);
}

View File

@@ -0,0 +1,12 @@
package sonia.scm.repository.spi;
import org.eclipse.jgit.revwalk.RevCommit;
import java.util.Optional;
public class GitRevisionExtractor {
static String extractRevisionFromRevCommit(RevCommit revCommit) {
return revCommit.toString().split(" ")[1];
}
}

View File

@@ -12,6 +12,7 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.junit.Rule;
import org.junit.Test;
import sonia.scm.NoChangesMadeException;
import sonia.scm.NotFoundException;
import sonia.scm.repository.Person;
import sonia.scm.repository.api.MergeCommandResult;
@@ -70,6 +71,8 @@ public class GitMergeCommandTest extends AbstractGitCommandTestBase {
MergeCommandResult mergeCommandResult = command.merge(request);
assertThat(mergeCommandResult.isSuccess()).isTrue();
assertThat(mergeCommandResult.getRevisionToMerge()).isEqualTo("91b99de908fcd04772798a31c308a64aea1a5523");
assertThat(mergeCommandResult.getTargetRevision()).isEqualTo("fcd0ef1831e4002ac43ea539f4094334c79ea9ec");
Repository repository = createContext().open();
Iterable<RevCommit> commits = new Git(repository).log().add(repository.resolve("master")).setMaxCount(1).call();
@@ -106,7 +109,7 @@ public class GitMergeCommandTest extends AbstractGitCommandTestBase {
assertThat(mergeCommit.getParent(1).name()).isEqualTo("d81ad6c63d7e2162308d69637b339dedd1d9201c");
}
@Test
@Test(expected = NoChangesMadeException.class)
public void shouldNotMergeTwice() throws IOException, GitAPIException {
GitMergeCommand command = createCommand();
MergeCommandRequest request = new MergeCommandRequest();
@@ -120,15 +123,9 @@ public class GitMergeCommandTest extends AbstractGitCommandTestBase {
assertThat(mergeCommandResult.isSuccess()).isTrue();
Repository repository = createContext().open();
ObjectId firstMergeCommit = new Git(repository).log().add(repository.resolve("master")).setMaxCount(1).call().iterator().next().getId();
new Git(repository).log().add(repository.resolve("master")).setMaxCount(1).call().iterator().next().getId();
MergeCommandResult secondMergeCommandResult = command.merge(request);
assertThat(secondMergeCommandResult.isSuccess()).isTrue();
ObjectId secondMergeCommit = new Git(repository).log().add(repository.resolve("master")).setMaxCount(1).call().iterator().next().getId();
assertThat(secondMergeCommit).isEqualTo(firstMergeCommit);
command.merge(request);
}
@Test
@@ -234,6 +231,8 @@ public class GitMergeCommandTest extends AbstractGitCommandTestBase {
Repository repository = createContext().open();
assertThat(mergeCommandResult.isSuccess()).isTrue();
assertThat(mergeCommandResult.getRevisionToMerge()).isEqualTo(mergeCommandResult.getNewHeadRevision());
assertThat(mergeCommandResult.getTargetRevision()).isEqualTo("fcd0ef1831e4002ac43ea539f4094334c79ea9ec");
Iterable<RevCommit> commits = new Git(repository).log().add(repository.resolve("master")).setMaxCount(1).call();
RevCommit mergeCommit = commits.iterator().next();
@@ -284,6 +283,9 @@ public class GitMergeCommandTest extends AbstractGitCommandTestBase {
request.setAuthor(new Person("Dirk Gently", "dirk@holistic.det"));
MergeCommandResult mergeCommandResult = command.merge(request);
assertThat(mergeCommandResult.getNewHeadRevision()).isEqualTo("35597e9e98fe53167266583848bfef985c2adb27");
assertThat(mergeCommandResult.getRevisionToMerge()).isEqualTo("35597e9e98fe53167266583848bfef985c2adb27");
assertThat(mergeCommandResult.getTargetRevision()).isEqualTo("fcd0ef1831e4002ac43ea539f4094334c79ea9ec");
assertThat(mergeCommandResult.isSuccess()).isTrue();

View File

@@ -0,0 +1,21 @@
package sonia.scm.repository.spi;
import org.eclipse.jgit.revwalk.RevCommit;
import org.junit.jupiter.api.Test;
import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class GitRevisionExtractorTest {
@Test
void shouldReturnRevisionFromRevCommit() {
RevCommit revCommit = mock(RevCommit.class);
when(revCommit.toString()).thenReturn("commit 123456abcdef -t 4561");
String revision = GitRevisionExtractor.extractRevisionFromRevCommit(revCommit);
assertThat(revision).isEqualTo("123456abcdef");
}
}

View File

@@ -336,7 +336,7 @@ exports[`Storyshots DateFromNow Default 1`] = `
exports[`Storyshots Forms|Checkbox Default 1`] = `
<div
className="sc-caSCKo brLbbv"
className="sc-gisBJw jHakbY"
>
<div
className="field"
@@ -381,7 +381,7 @@ exports[`Storyshots Forms|Checkbox Default 1`] = `
exports[`Storyshots Forms|Checkbox Disabled 1`] = `
<div
className="sc-caSCKo brLbbv"
className="sc-gisBJw jHakbY"
>
<div
className="field"
@@ -409,10 +409,10 @@ exports[`Storyshots Forms|Checkbox Disabled 1`] = `
exports[`Storyshots Forms|Radio Default 1`] = `
<div
className="sc-gisBJw jHakbY"
className="sc-kjoXOD hVPZau"
>
<label
className="radio"
className="sc-cMljjf kOqpHe radio"
>
<input
checked={false}
@@ -423,7 +423,7 @@ exports[`Storyshots Forms|Radio Default 1`] = `
Not checked
</label>
<label
className="radio"
className="sc-cMljjf kOqpHe radio"
>
<input
checked={true}
@@ -438,10 +438,10 @@ exports[`Storyshots Forms|Radio Default 1`] = `
exports[`Storyshots Forms|Radio Disabled 1`] = `
<div
className="sc-gisBJw jHakbY"
className="sc-kjoXOD hVPZau"
>
<label
className="radio"
className="sc-cMljjf kOqpHe radio"
disabled={true}
>
<input
@@ -458,7 +458,7 @@ exports[`Storyshots Forms|Radio Disabled 1`] = `
exports[`Storyshots Forms|Textarea OnCancel 1`] = `
<div
className="sc-kjoXOD hVPZau"
className="sc-cHGsZl klfJMr"
>
<div
className="field"
@@ -481,7 +481,7 @@ exports[`Storyshots Forms|Textarea OnCancel 1`] = `
exports[`Storyshots Forms|Textarea OnChange 1`] = `
<div
className="sc-kjoXOD hVPZau"
className="sc-cHGsZl klfJMr"
>
<div
className="field"
@@ -508,7 +508,7 @@ exports[`Storyshots Forms|Textarea OnChange 1`] = `
exports[`Storyshots Forms|Textarea OnSubmit 1`] = `
<div
className="sc-kjoXOD hVPZau"
className="sc-cHGsZl klfJMr"
>
<div
className="field"
@@ -2391,7 +2391,7 @@ PORT_NUMBER =
exports[`Storyshots Table|Table Default 1`] = `
<table
className="sc-jhAzac hmXDXQ table content is-hoverable"
className="sc-fBuWsC eeihxG table content is-hoverable"
>
<thead>
<tr>
@@ -2409,7 +2409,7 @@ exports[`Storyshots Table|Table Default 1`] = `
>
Last Name
<i
className="fas fa-sort-amount-down has-text-grey-light sc-hzDkRC escBde"
className="fas fa-sort-amount-down has-text-grey-light sc-jhAzac gDbcZp"
/>
</th>
<th
@@ -2482,7 +2482,7 @@ exports[`Storyshots Table|Table Empty 1`] = `
exports[`Storyshots Table|Table TextColumn 1`] = `
<table
className="sc-jhAzac hmXDXQ table content is-hoverable"
className="sc-fBuWsC eeihxG table content is-hoverable"
>
<thead>
<tr>
@@ -2494,7 +2494,7 @@ exports[`Storyshots Table|Table TextColumn 1`] = `
>
Id
<i
className="fas fa-sort-alpha-down has-text-grey-light sc-hzDkRC escBde"
className="fas fa-sort-alpha-down has-text-grey-light sc-jhAzac gDbcZp"
/>
</th>
<th
@@ -2505,7 +2505,7 @@ exports[`Storyshots Table|Table TextColumn 1`] = `
>
Name
<i
className="fas fa-sort-alpha-down has-text-grey-light sc-hzDkRC escBde"
className="fas fa-sort-alpha-down has-text-grey-light sc-jhAzac gDbcZp"
/>
</th>
<th
@@ -2516,7 +2516,7 @@ exports[`Storyshots Table|Table TextColumn 1`] = `
>
Description
<i
className="fas fa-sort-alpha-down has-text-grey-light sc-hzDkRC escBde"
className="fas fa-sort-alpha-down has-text-grey-light sc-jhAzac gDbcZp"
/>
</th>
</tr>

View File

@@ -1,5 +1,11 @@
import React, { ChangeEvent } from "react";
import { Help } from "../index";
import styled from "styled-components";
const StyledRadio = styled.label`
margin-right: 0.5em;
`;
type Props = {
label?: string;
@@ -33,7 +39,7 @@ class Radio extends React.Component<Props> {
because jsx label does not the custom disabled attribute
but bulma does.
// @ts-ignore */}
<label className="radio" disabled={this.props.disabled}>
<StyledRadio className="radio" disabled={this.props.disabled}>
<input
type="radio"
name={this.props.name}
@@ -44,7 +50,7 @@ class Radio extends React.Component<Props> {
/>{" "}
{this.props.label}
{this.renderHelp()}
</label>
</StyledRadio>
</>
);
}

View File

@@ -7,8 +7,11 @@ import parser from "gitdiff-parser";
import Loading from "../Loading";
import Diff from "./Diff";
import { DiffObjectProps, File } from "./DiffTypes";
import { NotFoundError } from "../errors";
import { Notification } from "../index";
import {withTranslation, WithTranslation} from "react-i18next";
type Props = DiffObjectProps & {
type Props = WithTranslation & DiffObjectProps & {
url: string;
defaultCollapse?: boolean;
};
@@ -66,6 +69,9 @@ class LoadingDiff extends React.Component<Props, State> {
render() {
const { diff, loading, error } = this.state;
if (error) {
if (error instanceof NotFoundError) {
return <Notification type="info">{this.props.t("changesets.noChangesets")}</Notification>;
}
return <ErrorNotification error={error} />;
} else if (loading) {
return <Loading />;
@@ -77,4 +83,4 @@ class LoadingDiff extends React.Component<Props, State> {
}
}
export default LoadingDiff;
export default withTranslation("repos")(LoadingDiff);

View File

@@ -28,7 +28,7 @@ class ChangesetDiff extends React.Component<Props> {
return <Notification type="danger">{t("changeset.diffNotSupported")}</Notification>;
} else {
const url = this.createUrl(changeset);
return <LoadingDiff url={url} defaultCollapse={defaultCollapse} />;
return <LoadingDiff url={url} defaultCollapse={defaultCollapse} sideBySide={false}/>;
}
}
}

View File

@@ -0,0 +1,42 @@
#!/usr/bin/env node
/* eslint-disable no-console */
const { spawnSync } = require("child_process");
const commands = ["postinstall"];
const args = process.argv.slice(2);
const commandIndex = args.findIndex(arg => {
return commands.includes(arg);
});
const command = commandIndex === -1 ? args[0] : args[commandIndex];
const nodeArgs = commandIndex > 0 ? args.slice(0, commandIndex) : [];
if (commands.includes(command)) {
const result = spawnSync(
"node",
nodeArgs.concat(require.resolve("../src/commands/" + command)).concat(args.slice(commandIndex + 1)),
{ stdio: "inherit" }
);
if (result.signal) {
if (result.signal === "SIGKILL") {
console.log(
"The build failed because the process exited too early. " +
"This probably means the system ran out of memory or someone called " +
"`kill -9` on the process."
);
} else if (result.signal === "SIGTERM") {
console.log(
"The build failed because the process exited too early. " +
"Someone might have called `kill` or `killall`, or the system could " +
"be shutting down."
);
}
process.exit(1);
}
process.exit(result.status);
} else {
console.log(`Unknown script "${command}".`);
console.log("Perhaps you need to update ui-plugins?");
}

View File

@@ -2,14 +2,27 @@
"name": "@scm-manager/ui-plugins",
"version": "2.0.0-SNAPSHOT",
"license": "BSD-3-Clause",
"bin": {
"ui-plugins": "./bin/ui-plugins.js"
},
"dependencies": {
"@scm-manager/ui-components": "^2.0.0-SNAPSHOT",
"@scm-manager/ui-extensions": "^2.0.0-SNAPSHOT",
"classnames": "^2.2.6",
"query-string": "^5.0.1",
"react": "^16.10.2",
"react-i18next": "^10.13.1",
"react-redux": "^5.0.7",
"react-router-dom": "^5.1.2",
"redux": "^4.0.0",
"styled-components": "^4.4.0"
},
"devDependencies": {
"@scm-manager/babel-preset": "^2.0.0-SNAPSHOT",
"@scm-manager/eslint-config": "^2.0.0-SNAPSHOT",
"@scm-manager/jest-preset": "^2.0.0-SNAPSHOT",
"@scm-manager/prettier-config": "^2.0.0-SNAPSHOT",
"@scm-manager/tsconfig": "^2.0.0-SNAPSHOT",
"@scm-manager/ui-components": "^2.0.0-SNAPSHOT",
"@scm-manager/ui-extensions": "^2.0.0-SNAPSHOT",
"@scm-manager/ui-scripts": "^2.0.0-SNAPSHOT",
"@scm-manager/ui-tests": "^2.0.0-SNAPSHOT",
"@scm-manager/ui-types": "^2.0.0-SNAPSHOT",
@@ -23,15 +36,7 @@
"@types/react-redux": "5.0.7",
"@types/react-router-dom": "^5.1.0",
"@types/styled-components": "^4.1.19",
"classnames": "^2.2.6",
"jest": "^24.9.0",
"query-string": "^5.0.1",
"react": "^16.10.2",
"react-i18next": "^10.13.1",
"react-redux": "^5.0.7",
"react-router-dom": "^5.1.2",
"redux": "^4.0.0",
"styled-components": "^4.4.0"
"jest": "^24.9.0"
},
"publishConfig": {
"access": "public"

View File

@@ -0,0 +1,49 @@
/* eslint-disable no-console */
const path = require("path");
const fs = require("fs");
const { spawnSync } = require("child_process");
const packageJsonPath = path.join(process.cwd(), "package.json");
const packageJSON = JSON.parse(fs.readFileSync(packageJsonPath, "UTF-8"));
const reference = require("../../package.json");
const sync = (left, right, key) => {
if (!right[key]) {
right[key] = {};
}
let changed = false;
const keys = Object.keys(left[key]);
keys.forEach(name => {
if (right[key][name] !== left[key][name]) {
console.log(name, "has changed from", right[key][name], "to", left[key][name]);
right[key][name] = left[key][name];
changed = true;
}
});
return changed;
};
const update = () => {
let dep = sync(reference, packageJSON, "dependencies");
let devDep = sync(reference, packageJSON, "devDependencies");
return dep || devDep;
};
if (update()) {
console.log("dependencies changed, install new dependencies");
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJSON, null, " "), { encoding: "UTF-8" });
const result = spawnSync("yarn", ["install"], { stdio: "inherit" });
if (result.error) {
console.log("could not start yarn command:", result.error);
process.exit(2);
} else if (result.status !== 0) {
console.log("yarn process ends with status code:", result.status);
process.exit(3);
}
}

View File

@@ -1,4 +1,5 @@
#!/usr/bin/env node
/* eslint-disable no-console */
const { spawnSync } = require("child_process");
const commands = ["plugin", "plugin-watch", "publish", "version"];
@@ -15,9 +16,7 @@ const nodeArgs = commandIndex > 0 ? args.slice(0, commandIndex) : [];
if (commands.includes(command)) {
const result = spawnSync(
"node",
nodeArgs
.concat(require.resolve("../src/commands/" + command))
.concat(args.slice(commandIndex + 1)),
nodeArgs.concat(require.resolve("../src/commands/" + command)).concat(args.slice(commandIndex + 1)),
{ stdio: "inherit" }
);
if (result.signal) {
@@ -38,9 +37,6 @@ if (commands.includes(command)) {
}
process.exit(result.status);
} else {
console.log("Unknown script \"" + command + "\".");
console.log("Perhaps you need to update react-scripts?");
console.log(
"See: https://facebook.github.io/create-react-app/docs/updating-to-new-releases"
);
console.log(`Unknown script "${command}".`);
console.log("Perhaps you need to update ui-scripts?");
}

View File

@@ -813,6 +813,12 @@ form .field:not(.is-grouped) {
}
}
// radio
//overwrite bulma's default margin
.radio + .radio {
margin-left: 0;
}
// cursor
.has-cursor-pointer {
cursor: pointer;

View File

@@ -72,7 +72,7 @@
"changesets": {
"errorTitle": "Fehler",
"errorSubtitle": "Changesets konnten nicht abgerufen werden",
"noChangesets": "Keine Changesets in diesem Branch gefunden.",
"noChangesets": "Keine Changesets in diesem Branch gefunden. Die Commits könnten gelöscht worden sein.",
"branchSelectorLabel": "Branches",
"collapseDiffs": "Auf-/Zuklappen"
},
@@ -99,7 +99,7 @@
"file-tree": {
"name": "Name",
"length": "Größe",
"lastModified": "Zuletzt bearbeitet",
"commitDate": "Commitdatum",
"description": "Beschreibung",
"branch": "Branch",
"notYetComputed": "Noch nicht berechnet; Der Wert wird in Kürze aktualisiert",
@@ -111,7 +111,7 @@
"downloadButton": "Download",
"path": "Pfad",
"branch": "Branch",
"lastModified": "Zuletzt bearbeitet",
"commitDate": "Commitdatum",
"description": "Beschreibung",
"size": "Größe"
},

View File

@@ -72,7 +72,7 @@
"changesets": {
"errorTitle": "Error",
"errorSubtitle": "Could not fetch changesets",
"noChangesets": "No changesets found for this branch.",
"noChangesets": "No changesets found for this branch. The commits could have been removed.",
"branchSelectorLabel": "Branches",
"collapseDiffs": "Collapse"
},
@@ -99,7 +99,7 @@
"file-tree": {
"name": "Name",
"length": "Length",
"lastModified": "Last modified",
"commitDate": "Commit date",
"description": "Description",
"branch": "Branch",
"notYetComputed": "Not yet computed, will be updated in a short while",
@@ -111,7 +111,7 @@
"downloadButton": "Download",
"path": "Path",
"branch": "Branch",
"lastModified": "Last modified",
"commitDate": "Commit date",
"description": "Description",
"size": "Size"
},

View File

@@ -72,7 +72,7 @@
"changesets": {
"errorTitle": "Error",
"errorSubtitle": "No se han podido recuperar los changesets",
"noChangesets": "No se han encontrado changesets para esta rama branch.",
"noChangesets": "No se han encontrado changesets para esta rama branch. Los commits podrían haber sido eliminados.",
"branchSelectorLabel": "Ramas",
"collapseDiffs": "Colapso"
},
@@ -99,9 +99,11 @@
"file-tree": {
"name": "Nombre",
"length": "Longitud",
"lastModified": "Última modificación",
"commitDate": "Fecha de cometer",
"description": "Descripción",
"branch": "Rama"
"branch": "Rama",
"notYetComputed": "Aún no calculado, se actualizará en poco tiempo",
"computationAborted": "El cálculo tomó demasiado tiempo y fue abortado"
},
"content": {
"historyButton": "Historia",
@@ -109,7 +111,7 @@
"downloadButton": "Descargar",
"path": "Ruta",
"branch": "Rama",
"lastModified": "Última modificación",
"commitDate": "Fecha de cometer",
"description": "Discripción",
"size": "tamaño"
},

View File

@@ -147,7 +147,7 @@ class Content extends React.Component<Props, State> {
<td>{fileSize}</td>
</tr>
<tr>
<td>{t("sources.content.lastModified")}</td>
<td>{t("sources.content.commitDate")}</td>
<td>{date}</td>
</tr>
<tr>

View File

@@ -6,6 +6,7 @@ import { getFailure } from "../../../modules/failure";
export const FETCH_SOURCES = "scm/repos/FETCH_SOURCES";
export const FETCH_SOURCES_PENDING = `${FETCH_SOURCES}_${types.PENDING_SUFFIX}`;
export const FETCH_UPDATES_PENDING = `${FETCH_SOURCES}_UPDATE_PENDING`;
export const FETCH_SOURCES_SUCCESS = `${FETCH_SOURCES}_${types.SUCCESS_SUFFIX}`;
export const FETCH_SOURCES_FAILURE = `${FETCH_SOURCES}_${types.FAILURE_SUFFIX}`;
@@ -61,7 +62,7 @@ export function updateSourcesPending(
currentSources: any
): Action {
return {
type: "UPDATE_PENDING",
type: FETCH_UPDATES_PENDING,
payload: { updatePending: true, sources: currentSources },
itemId: createItemId(repository, revision, path)
};
@@ -97,7 +98,7 @@ export default function reducer(
type: "UNKNOWN"
}
): any {
if (action.itemId && (action.type === FETCH_SOURCES_SUCCESS || action.type === "UPDATE_PENDING")) {
if (action.itemId && (action.type === FETCH_SOURCES_SUCCESS || action.type === FETCH_UPDATES_PENDING)) {
return {
...state,
[action.itemId]: action.payload

2785
yarn.lock

File diff suppressed because it is too large Load Diff