mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
merge with default branch
This commit is contained in:
8
Jenkinsfile
vendored
8
Jenkinsfile
vendored
@@ -55,7 +55,13 @@ node('docker') {
|
|||||||
if (isMainBranch()) {
|
if (isMainBranch()) {
|
||||||
|
|
||||||
stage('Lifecycle') {
|
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') {
|
stage('Archive') {
|
||||||
|
|||||||
@@ -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.
|
* case you can use {@link #getFilesWithConflict()} to get a list of files with merge conflicts.
|
||||||
*/
|
*/
|
||||||
public class MergeCommandResult {
|
public class MergeCommandResult {
|
||||||
|
|
||||||
private final Collection<String> filesWithConflict;
|
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.filesWithConflict = filesWithConflict;
|
||||||
|
this.targetRevision = targetRevision;
|
||||||
|
this.revisionToMerge = revisionToMerge;
|
||||||
|
this.newHeadRevision = newHeadRevision;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MergeCommandResult success() {
|
public static MergeCommandResult success(String targetRevision, String revisionToMerge, String newHeadRevision) {
|
||||||
return new MergeCommandResult(emptyList());
|
return new MergeCommandResult(emptyList(), targetRevision, revisionToMerge, newHeadRevision);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MergeCommandResult failure(Collection<String> filesWithConflict) {
|
public static MergeCommandResult failure(String targetRevision, String revisionToMerge, Collection<String> filesWithConflict) {
|
||||||
return new MergeCommandResult(new HashSet<>(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.
|
* merge conflicts. In this case you can use {@link #getFilesWithConflict()} to check what files could not be merged.
|
||||||
*/
|
*/
|
||||||
public boolean isSuccess() {
|
public boolean isSuccess() {
|
||||||
return filesWithConflict.isEmpty();
|
return filesWithConflict.isEmpty() && newHeadRevision != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,4 +48,26 @@ public class MergeCommandResult {
|
|||||||
public Collection<String> getFilesWithConflict() {
|
public Collection<String> getFilesWithConflict() {
|
||||||
return unmodifiableCollection(filesWithConflict);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,12 @@ import sonia.scm.repository.api.MergeStrategy;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public interface MergeCommand {
|
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);
|
MergeCommandResult merge(MergeCommandRequest request);
|
||||||
|
|
||||||
MergeDryRunCommandResult dryRun(MergeCommandRequest request);
|
MergeDryRunCommandResult dryRun(MergeCommandRequest request);
|
||||||
|
|||||||
@@ -8,6 +8,14 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.UUID;
|
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 {
|
public final class CopyOnWrite {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(CopyOnWrite.class);
|
private static final Logger LOG = LoggerFactory.getLogger(CopyOnWrite.class);
|
||||||
|
|||||||
@@ -186,6 +186,10 @@ class AbstractGitCommand
|
|||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sonia.scm.repository.Repository getRepository() {
|
||||||
|
return repository;
|
||||||
|
}
|
||||||
|
|
||||||
void checkOutBranch(String branchName) throws IOException {
|
void checkOutBranch(String branchName) throws IOException {
|
||||||
try {
|
try {
|
||||||
clone.checkout().setName(branchName).call();
|
clone.checkout().setName(branchName).call();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package sonia.scm.repository.spi;
|
|||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import org.eclipse.jgit.diff.DiffEntry;
|
import org.eclipse.jgit.diff.DiffEntry;
|
||||||
|
import org.eclipse.jgit.errors.MissingObjectException;
|
||||||
import org.eclipse.jgit.lib.ObjectId;
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
import org.eclipse.jgit.revwalk.RevCommit;
|
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.EmptyTreeIterator;
|
||||||
import org.eclipse.jgit.treewalk.TreeWalk;
|
import org.eclipse.jgit.treewalk.TreeWalk;
|
||||||
import org.eclipse.jgit.treewalk.filter.PathFilter;
|
import org.eclipse.jgit.treewalk.filter.PathFilter;
|
||||||
|
import sonia.scm.ContextEntry;
|
||||||
|
import sonia.scm.NotFoundException;
|
||||||
import sonia.scm.repository.GitUtil;
|
import sonia.scm.repository.GitUtil;
|
||||||
import sonia.scm.util.Util;
|
import sonia.scm.util.Util;
|
||||||
|
|
||||||
@@ -38,7 +41,15 @@ final class Differ implements AutoCloseable {
|
|||||||
RevWalk walk = new RevWalk(repository);
|
RevWalk walk = new RevWalk(repository);
|
||||||
|
|
||||||
ObjectId revision = repository.resolve(request.getRevision());
|
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);
|
walk.markStart(commit);
|
||||||
commit = walk.next();
|
commit = walk.next();
|
||||||
@@ -46,34 +57,25 @@ final class Differ implements AutoCloseable {
|
|||||||
treeWalk.reset();
|
treeWalk.reset();
|
||||||
treeWalk.setRecursive(true);
|
treeWalk.setRecursive(true);
|
||||||
|
|
||||||
if (Util.isNotEmpty(request.getPath()))
|
if (Util.isNotEmpty(request.getPath())) {
|
||||||
{
|
|
||||||
treeWalk.setFilter(PathFilter.create(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 otherRevision = repository.resolve(request.getAncestorChangeset());
|
||||||
ObjectId ancestorId = GitUtil.computeCommonAncestor(repository, revision, otherRevision);
|
ObjectId ancestorId = GitUtil.computeCommonAncestor(repository, revision, otherRevision);
|
||||||
RevTree tree = walk.parseCommit(ancestorId).getTree();
|
RevTree tree = walk.parseCommit(ancestorId).getTree();
|
||||||
treeWalk.addTree(tree);
|
treeWalk.addTree(tree);
|
||||||
}
|
} else if (commit.getParentCount() > 0) {
|
||||||
else if (commit.getParentCount() > 0)
|
|
||||||
{
|
|
||||||
RevTree tree = commit.getParent(0).getTree();
|
RevTree tree = commit.getParent(0).getTree();
|
||||||
|
|
||||||
if (tree != null)
|
if (tree != null) {
|
||||||
{
|
|
||||||
treeWalk.addTree(tree);
|
treeWalk.addTree(tree);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
treeWalk.addTree(new EmptyTreeIterator());
|
treeWalk.addTree(new EmptyTreeIterator());
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
treeWalk.addTree(new EmptyTreeIterator());
|
treeWalk.addTree(new EmptyTreeIterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import sonia.scm.repository.Repository;
|
|||||||
import sonia.scm.repository.api.MergeCommandResult;
|
import sonia.scm.repository.api.MergeCommandResult;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
class GitFastForwardIfPossible extends GitMergeStrategy {
|
class GitFastForwardIfPossible extends GitMergeStrategy {
|
||||||
|
|
||||||
@@ -22,7 +23,7 @@ class GitFastForwardIfPossible extends GitMergeStrategy {
|
|||||||
MergeResult fastForwardResult = mergeWithFastForwardOnlyMode();
|
MergeResult fastForwardResult = mergeWithFastForwardOnlyMode();
|
||||||
if (fastForwardResult.getMergeStatus().isSuccessful()) {
|
if (fastForwardResult.getMergeStatus().isSuccessful()) {
|
||||||
push();
|
push();
|
||||||
return MergeCommandResult.success();
|
return createSuccessResult(fastForwardResult.getNewHead().name());
|
||||||
} else {
|
} else {
|
||||||
return fallbackMerge.run();
|
return fallbackMerge.run();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,16 @@ package sonia.scm.repository.spi;
|
|||||||
import org.eclipse.jgit.api.Git;
|
import org.eclipse.jgit.api.Git;
|
||||||
import org.eclipse.jgit.api.MergeCommand;
|
import org.eclipse.jgit.api.MergeCommand;
|
||||||
import org.eclipse.jgit.api.MergeResult;
|
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.Repository;
|
||||||
import sonia.scm.repository.api.MergeCommandResult;
|
import sonia.scm.repository.api.MergeCommandResult;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static sonia.scm.repository.spi.GitRevisionExtractor.extractRevisionFromRevCommit;
|
||||||
|
|
||||||
class GitMergeCommit extends GitMergeStrategy {
|
class GitMergeCommit extends GitMergeStrategy {
|
||||||
|
|
||||||
@@ -21,11 +27,12 @@ class GitMergeCommit extends GitMergeStrategy {
|
|||||||
MergeResult result = doMergeInClone(mergeCommand);
|
MergeResult result = doMergeInClone(mergeCommand);
|
||||||
|
|
||||||
if (result.getMergeStatus().isSuccessful()) {
|
if (result.getMergeStatus().isSuccessful()) {
|
||||||
doCommit();
|
RevCommit revCommit = doCommit().orElseThrow(() -> new NoChangesMadeException(getRepository()));
|
||||||
push();
|
push();
|
||||||
return MergeCommandResult.success();
|
return createSuccessResult(extractRevisionFromRevCommit(revCommit));
|
||||||
} else {
|
} else {
|
||||||
return analyseFailure(result);
|
return analyseFailure(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.eclipse.jgit.api.MergeCommand;
|
|||||||
import org.eclipse.jgit.api.MergeResult;
|
import org.eclipse.jgit.api.MergeResult;
|
||||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||||
import org.eclipse.jgit.lib.ObjectId;
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
|
import org.eclipse.jgit.revwalk.RevCommit;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import sonia.scm.repository.InternalRepositoryException;
|
import sonia.scm.repository.InternalRepositoryException;
|
||||||
@@ -14,6 +15,7 @@ import sonia.scm.repository.api.MergeCommandResult;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
abstract class GitMergeStrategy extends AbstractGitCommand.GitCloneWorker<MergeCommandResult> {
|
abstract class GitMergeStrategy extends AbstractGitCommand.GitCloneWorker<MergeCommandResult> {
|
||||||
|
|
||||||
@@ -24,37 +26,57 @@ abstract class GitMergeStrategy extends AbstractGitCommand.GitCloneWorker<MergeC
|
|||||||
"",
|
"",
|
||||||
"Automatic merge by SCM-Manager.");
|
"Automatic merge by SCM-Manager.");
|
||||||
|
|
||||||
private final String target;
|
private final String targetBranch;
|
||||||
private final String toMerge;
|
private final ObjectId targetRevision;
|
||||||
|
private final String branchToMerge;
|
||||||
|
private final ObjectId revisionToMerge;
|
||||||
private final Person author;
|
private final Person author;
|
||||||
private final String messageTemplate;
|
private final String messageTemplate;
|
||||||
|
|
||||||
GitMergeStrategy(Git clone, MergeCommandRequest request, GitContext context, sonia.scm.repository.Repository repository) {
|
GitMergeStrategy(Git clone, MergeCommandRequest request, GitContext context, sonia.scm.repository.Repository repository) {
|
||||||
super(clone, context, repository);
|
super(clone, context, repository);
|
||||||
this.target = request.getTargetBranch();
|
this.targetBranch = request.getTargetBranch();
|
||||||
this.toMerge = request.getBranchToMerge();
|
this.branchToMerge = request.getBranchToMerge();
|
||||||
this.author = request.getAuthor();
|
this.author = request.getAuthor();
|
||||||
this.messageTemplate = request.getMessageTemplate();
|
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 doMergeInClone(MergeCommand mergeCommand) throws IOException {
|
||||||
MergeResult result;
|
MergeResult result;
|
||||||
try {
|
try {
|
||||||
ObjectId sourceRevision = resolveRevision(toMerge);
|
ObjectId sourceRevision = resolveRevision(branchToMerge);
|
||||||
mergeCommand
|
mergeCommand
|
||||||
.setCommit(false) // we want to set the author manually
|
.setCommit(false) // we want to set the author manually
|
||||||
.include(toMerge, sourceRevision);
|
.include(branchToMerge, sourceRevision);
|
||||||
|
|
||||||
result = mergeCommand.call();
|
result = mergeCommand.call();
|
||||||
} catch (GitAPIException e) {
|
} 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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void doCommit() {
|
Optional<RevCommit> doCommit() {
|
||||||
logger.debug("merged branch {} into {}", toMerge, target);
|
logger.debug("merged branch {} into {}", branchToMerge, targetBranch);
|
||||||
doCommit(MessageFormat.format(determineMessageTemplate(), toMerge, target), author);
|
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() {
|
private String determineMessageTemplate() {
|
||||||
@@ -66,7 +88,7 @@ abstract class GitMergeStrategy extends AbstractGitCommand.GitCloneWorker<MergeC
|
|||||||
}
|
}
|
||||||
|
|
||||||
MergeCommandResult analyseFailure(MergeResult result) {
|
MergeCommandResult analyseFailure(MergeResult result) {
|
||||||
logger.info("could not merge branch {} into {} due to conflict in paths {}", toMerge, target, result.getConflicts().keySet());
|
logger.info("could not merge branch {} into {} due to conflict in paths {}", branchToMerge, targetBranch, result.getConflicts().keySet());
|
||||||
return MergeCommandResult.failure(result.getConflicts().keySet());
|
return MergeCommandResult.failure(targetRevision.name(), revisionToMerge.name(), result.getConflicts().keySet());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
package sonia.scm.repository.spi;
|
package sonia.scm.repository.spi;
|
||||||
|
|
||||||
import org.eclipse.jgit.api.Git;
|
import org.eclipse.jgit.api.Git;
|
||||||
|
import org.eclipse.jgit.api.MergeCommand;
|
||||||
import org.eclipse.jgit.api.MergeResult;
|
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.Repository;
|
||||||
import sonia.scm.repository.api.MergeCommandResult;
|
import sonia.scm.repository.api.MergeCommandResult;
|
||||||
import org.eclipse.jgit.api.MergeCommand;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static sonia.scm.repository.spi.GitRevisionExtractor.extractRevisionFromRevCommit;
|
||||||
|
|
||||||
class GitMergeWithSquash extends GitMergeStrategy {
|
class GitMergeWithSquash extends GitMergeStrategy {
|
||||||
|
|
||||||
GitMergeWithSquash(Git clone, MergeCommandRequest request, GitContext context, Repository repository) {
|
GitMergeWithSquash(Git clone, MergeCommandRequest request, GitContext context, Repository repository) {
|
||||||
@@ -21,9 +25,9 @@ class GitMergeWithSquash extends GitMergeStrategy {
|
|||||||
MergeResult result = doMergeInClone(mergeCommand);
|
MergeResult result = doMergeInClone(mergeCommand);
|
||||||
|
|
||||||
if (result.getMergeStatus().isSuccessful()) {
|
if (result.getMergeStatus().isSuccessful()) {
|
||||||
doCommit();
|
RevCommit revCommit = doCommit().orElseThrow(() -> new NoChangesMadeException(getRepository()));
|
||||||
push();
|
push();
|
||||||
return MergeCommandResult.success();
|
return MergeCommandResult.success(getTargetRevision().name(), revCommit.name(), extractRevisionFromRevCommit(revCommit));
|
||||||
} else {
|
} else {
|
||||||
return analyseFailure(result);
|
return analyseFailure(result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ import org.eclipse.jgit.lib.Repository;
|
|||||||
import org.eclipse.jgit.revwalk.RevCommit;
|
import org.eclipse.jgit.revwalk.RevCommit;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import sonia.scm.NoChangesMadeException;
|
||||||
import sonia.scm.NotFoundException;
|
import sonia.scm.NotFoundException;
|
||||||
import sonia.scm.repository.Person;
|
import sonia.scm.repository.Person;
|
||||||
import sonia.scm.repository.api.MergeCommandResult;
|
import sonia.scm.repository.api.MergeCommandResult;
|
||||||
@@ -70,6 +71,8 @@ public class GitMergeCommandTest extends AbstractGitCommandTestBase {
|
|||||||
MergeCommandResult mergeCommandResult = command.merge(request);
|
MergeCommandResult mergeCommandResult = command.merge(request);
|
||||||
|
|
||||||
assertThat(mergeCommandResult.isSuccess()).isTrue();
|
assertThat(mergeCommandResult.isSuccess()).isTrue();
|
||||||
|
assertThat(mergeCommandResult.getRevisionToMerge()).isEqualTo("91b99de908fcd04772798a31c308a64aea1a5523");
|
||||||
|
assertThat(mergeCommandResult.getTargetRevision()).isEqualTo("fcd0ef1831e4002ac43ea539f4094334c79ea9ec");
|
||||||
|
|
||||||
Repository repository = createContext().open();
|
Repository repository = createContext().open();
|
||||||
Iterable<RevCommit> commits = new Git(repository).log().add(repository.resolve("master")).setMaxCount(1).call();
|
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");
|
assertThat(mergeCommit.getParent(1).name()).isEqualTo("d81ad6c63d7e2162308d69637b339dedd1d9201c");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = NoChangesMadeException.class)
|
||||||
public void shouldNotMergeTwice() throws IOException, GitAPIException {
|
public void shouldNotMergeTwice() throws IOException, GitAPIException {
|
||||||
GitMergeCommand command = createCommand();
|
GitMergeCommand command = createCommand();
|
||||||
MergeCommandRequest request = new MergeCommandRequest();
|
MergeCommandRequest request = new MergeCommandRequest();
|
||||||
@@ -120,15 +123,9 @@ public class GitMergeCommandTest extends AbstractGitCommandTestBase {
|
|||||||
assertThat(mergeCommandResult.isSuccess()).isTrue();
|
assertThat(mergeCommandResult.isSuccess()).isTrue();
|
||||||
|
|
||||||
Repository repository = createContext().open();
|
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);
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -234,6 +231,8 @@ public class GitMergeCommandTest extends AbstractGitCommandTestBase {
|
|||||||
|
|
||||||
Repository repository = createContext().open();
|
Repository repository = createContext().open();
|
||||||
assertThat(mergeCommandResult.isSuccess()).isTrue();
|
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();
|
Iterable<RevCommit> commits = new Git(repository).log().add(repository.resolve("master")).setMaxCount(1).call();
|
||||||
RevCommit mergeCommit = commits.iterator().next();
|
RevCommit mergeCommit = commits.iterator().next();
|
||||||
@@ -284,6 +283,9 @@ public class GitMergeCommandTest extends AbstractGitCommandTestBase {
|
|||||||
request.setAuthor(new Person("Dirk Gently", "dirk@holistic.det"));
|
request.setAuthor(new Person("Dirk Gently", "dirk@holistic.det"));
|
||||||
|
|
||||||
MergeCommandResult mergeCommandResult = command.merge(request);
|
MergeCommandResult mergeCommandResult = command.merge(request);
|
||||||
|
assertThat(mergeCommandResult.getNewHeadRevision()).isEqualTo("35597e9e98fe53167266583848bfef985c2adb27");
|
||||||
|
assertThat(mergeCommandResult.getRevisionToMerge()).isEqualTo("35597e9e98fe53167266583848bfef985c2adb27");
|
||||||
|
assertThat(mergeCommandResult.getTargetRevision()).isEqualTo("fcd0ef1831e4002ac43ea539f4094334c79ea9ec");
|
||||||
|
|
||||||
assertThat(mergeCommandResult.isSuccess()).isTrue();
|
assertThat(mergeCommandResult.isSuccess()).isTrue();
|
||||||
|
|
||||||
|
|||||||
@@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -336,7 +336,7 @@ exports[`Storyshots DateFromNow Default 1`] = `
|
|||||||
|
|
||||||
exports[`Storyshots Forms|Checkbox Default 1`] = `
|
exports[`Storyshots Forms|Checkbox Default 1`] = `
|
||||||
<div
|
<div
|
||||||
className="sc-caSCKo brLbbv"
|
className="sc-gisBJw jHakbY"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className="field"
|
className="field"
|
||||||
@@ -381,7 +381,7 @@ exports[`Storyshots Forms|Checkbox Default 1`] = `
|
|||||||
|
|
||||||
exports[`Storyshots Forms|Checkbox Disabled 1`] = `
|
exports[`Storyshots Forms|Checkbox Disabled 1`] = `
|
||||||
<div
|
<div
|
||||||
className="sc-caSCKo brLbbv"
|
className="sc-gisBJw jHakbY"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className="field"
|
className="field"
|
||||||
@@ -409,10 +409,10 @@ exports[`Storyshots Forms|Checkbox Disabled 1`] = `
|
|||||||
|
|
||||||
exports[`Storyshots Forms|Radio Default 1`] = `
|
exports[`Storyshots Forms|Radio Default 1`] = `
|
||||||
<div
|
<div
|
||||||
className="sc-gisBJw jHakbY"
|
className="sc-kjoXOD hVPZau"
|
||||||
>
|
>
|
||||||
<label
|
<label
|
||||||
className="radio"
|
className="sc-cMljjf kOqpHe radio"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
checked={false}
|
checked={false}
|
||||||
@@ -423,7 +423,7 @@ exports[`Storyshots Forms|Radio Default 1`] = `
|
|||||||
Not checked
|
Not checked
|
||||||
</label>
|
</label>
|
||||||
<label
|
<label
|
||||||
className="radio"
|
className="sc-cMljjf kOqpHe radio"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
checked={true}
|
checked={true}
|
||||||
@@ -438,10 +438,10 @@ exports[`Storyshots Forms|Radio Default 1`] = `
|
|||||||
|
|
||||||
exports[`Storyshots Forms|Radio Disabled 1`] = `
|
exports[`Storyshots Forms|Radio Disabled 1`] = `
|
||||||
<div
|
<div
|
||||||
className="sc-gisBJw jHakbY"
|
className="sc-kjoXOD hVPZau"
|
||||||
>
|
>
|
||||||
<label
|
<label
|
||||||
className="radio"
|
className="sc-cMljjf kOqpHe radio"
|
||||||
disabled={true}
|
disabled={true}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
@@ -458,7 +458,7 @@ exports[`Storyshots Forms|Radio Disabled 1`] = `
|
|||||||
|
|
||||||
exports[`Storyshots Forms|Textarea OnCancel 1`] = `
|
exports[`Storyshots Forms|Textarea OnCancel 1`] = `
|
||||||
<div
|
<div
|
||||||
className="sc-kjoXOD hVPZau"
|
className="sc-cHGsZl klfJMr"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className="field"
|
className="field"
|
||||||
@@ -481,7 +481,7 @@ exports[`Storyshots Forms|Textarea OnCancel 1`] = `
|
|||||||
|
|
||||||
exports[`Storyshots Forms|Textarea OnChange 1`] = `
|
exports[`Storyshots Forms|Textarea OnChange 1`] = `
|
||||||
<div
|
<div
|
||||||
className="sc-kjoXOD hVPZau"
|
className="sc-cHGsZl klfJMr"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className="field"
|
className="field"
|
||||||
@@ -508,7 +508,7 @@ exports[`Storyshots Forms|Textarea OnChange 1`] = `
|
|||||||
|
|
||||||
exports[`Storyshots Forms|Textarea OnSubmit 1`] = `
|
exports[`Storyshots Forms|Textarea OnSubmit 1`] = `
|
||||||
<div
|
<div
|
||||||
className="sc-kjoXOD hVPZau"
|
className="sc-cHGsZl klfJMr"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className="field"
|
className="field"
|
||||||
@@ -2391,7 +2391,7 @@ PORT_NUMBER =
|
|||||||
|
|
||||||
exports[`Storyshots Table|Table Default 1`] = `
|
exports[`Storyshots Table|Table Default 1`] = `
|
||||||
<table
|
<table
|
||||||
className="sc-jhAzac hmXDXQ table content is-hoverable"
|
className="sc-fBuWsC eeihxG table content is-hoverable"
|
||||||
>
|
>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -2409,7 +2409,7 @@ exports[`Storyshots Table|Table Default 1`] = `
|
|||||||
>
|
>
|
||||||
Last Name
|
Last Name
|
||||||
<i
|
<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>
|
||||||
<th
|
<th
|
||||||
@@ -2482,7 +2482,7 @@ exports[`Storyshots Table|Table Empty 1`] = `
|
|||||||
|
|
||||||
exports[`Storyshots Table|Table TextColumn 1`] = `
|
exports[`Storyshots Table|Table TextColumn 1`] = `
|
||||||
<table
|
<table
|
||||||
className="sc-jhAzac hmXDXQ table content is-hoverable"
|
className="sc-fBuWsC eeihxG table content is-hoverable"
|
||||||
>
|
>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -2494,7 +2494,7 @@ exports[`Storyshots Table|Table TextColumn 1`] = `
|
|||||||
>
|
>
|
||||||
Id
|
Id
|
||||||
<i
|
<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>
|
||||||
<th
|
<th
|
||||||
@@ -2505,7 +2505,7 @@ exports[`Storyshots Table|Table TextColumn 1`] = `
|
|||||||
>
|
>
|
||||||
Name
|
Name
|
||||||
<i
|
<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>
|
||||||
<th
|
<th
|
||||||
@@ -2516,7 +2516,7 @@ exports[`Storyshots Table|Table TextColumn 1`] = `
|
|||||||
>
|
>
|
||||||
Description
|
Description
|
||||||
<i
|
<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>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
import React, { ChangeEvent } from "react";
|
import React, { ChangeEvent } from "react";
|
||||||
import { Help } from "../index";
|
import { Help } from "../index";
|
||||||
|
import styled from "styled-components";
|
||||||
|
|
||||||
|
|
||||||
|
const StyledRadio = styled.label`
|
||||||
|
margin-right: 0.5em;
|
||||||
|
`;
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
label?: string;
|
label?: string;
|
||||||
@@ -33,7 +39,7 @@ class Radio extends React.Component<Props> {
|
|||||||
because jsx label does not the custom disabled attribute
|
because jsx label does not the custom disabled attribute
|
||||||
but bulma does.
|
but bulma does.
|
||||||
// @ts-ignore */}
|
// @ts-ignore */}
|
||||||
<label className="radio" disabled={this.props.disabled}>
|
<StyledRadio className="radio" disabled={this.props.disabled}>
|
||||||
<input
|
<input
|
||||||
type="radio"
|
type="radio"
|
||||||
name={this.props.name}
|
name={this.props.name}
|
||||||
@@ -44,7 +50,7 @@ class Radio extends React.Component<Props> {
|
|||||||
/>{" "}
|
/>{" "}
|
||||||
{this.props.label}
|
{this.props.label}
|
||||||
{this.renderHelp()}
|
{this.renderHelp()}
|
||||||
</label>
|
</StyledRadio>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,11 @@ import parser from "gitdiff-parser";
|
|||||||
import Loading from "../Loading";
|
import Loading from "../Loading";
|
||||||
import Diff from "./Diff";
|
import Diff from "./Diff";
|
||||||
import { DiffObjectProps, File } from "./DiffTypes";
|
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;
|
url: string;
|
||||||
defaultCollapse?: boolean;
|
defaultCollapse?: boolean;
|
||||||
};
|
};
|
||||||
@@ -66,6 +69,9 @@ class LoadingDiff extends React.Component<Props, State> {
|
|||||||
render() {
|
render() {
|
||||||
const { diff, loading, error } = this.state;
|
const { diff, loading, error } = this.state;
|
||||||
if (error) {
|
if (error) {
|
||||||
|
if (error instanceof NotFoundError) {
|
||||||
|
return <Notification type="info">{this.props.t("changesets.noChangesets")}</Notification>;
|
||||||
|
}
|
||||||
return <ErrorNotification error={error} />;
|
return <ErrorNotification error={error} />;
|
||||||
} else if (loading) {
|
} else if (loading) {
|
||||||
return <Loading />;
|
return <Loading />;
|
||||||
@@ -77,4 +83,4 @@ class LoadingDiff extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default LoadingDiff;
|
export default withTranslation("repos")(LoadingDiff);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class ChangesetDiff extends React.Component<Props> {
|
|||||||
return <Notification type="danger">{t("changeset.diffNotSupported")}</Notification>;
|
return <Notification type="danger">{t("changeset.diffNotSupported")}</Notification>;
|
||||||
} else {
|
} else {
|
||||||
const url = this.createUrl(changeset);
|
const url = this.createUrl(changeset);
|
||||||
return <LoadingDiff url={url} defaultCollapse={defaultCollapse} />;
|
return <LoadingDiff url={url} defaultCollapse={defaultCollapse} sideBySide={false}/>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
42
scm-ui/ui-plugins/bin/ui-plugins.js
Executable file
42
scm-ui/ui-plugins/bin/ui-plugins.js
Executable 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?");
|
||||||
|
}
|
||||||
@@ -2,14 +2,27 @@
|
|||||||
"name": "@scm-manager/ui-plugins",
|
"name": "@scm-manager/ui-plugins",
|
||||||
"version": "2.0.0-SNAPSHOT",
|
"version": "2.0.0-SNAPSHOT",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
|
"bin": {
|
||||||
|
"ui-plugins": "./bin/ui-plugins.js"
|
||||||
|
},
|
||||||
"dependencies": {
|
"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/babel-preset": "^2.0.0-SNAPSHOT",
|
||||||
"@scm-manager/eslint-config": "^2.0.0-SNAPSHOT",
|
"@scm-manager/eslint-config": "^2.0.0-SNAPSHOT",
|
||||||
"@scm-manager/jest-preset": "^2.0.0-SNAPSHOT",
|
"@scm-manager/jest-preset": "^2.0.0-SNAPSHOT",
|
||||||
"@scm-manager/prettier-config": "^2.0.0-SNAPSHOT",
|
"@scm-manager/prettier-config": "^2.0.0-SNAPSHOT",
|
||||||
"@scm-manager/tsconfig": "^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-scripts": "^2.0.0-SNAPSHOT",
|
||||||
"@scm-manager/ui-tests": "^2.0.0-SNAPSHOT",
|
"@scm-manager/ui-tests": "^2.0.0-SNAPSHOT",
|
||||||
"@scm-manager/ui-types": "^2.0.0-SNAPSHOT",
|
"@scm-manager/ui-types": "^2.0.0-SNAPSHOT",
|
||||||
@@ -23,15 +36,7 @@
|
|||||||
"@types/react-redux": "5.0.7",
|
"@types/react-redux": "5.0.7",
|
||||||
"@types/react-router-dom": "^5.1.0",
|
"@types/react-router-dom": "^5.1.0",
|
||||||
"@types/styled-components": "^4.1.19",
|
"@types/styled-components": "^4.1.19",
|
||||||
"classnames": "^2.2.6",
|
"jest": "^24.9.0"
|
||||||
"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"
|
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
|||||||
49
scm-ui/ui-plugins/src/commands/postinstall.js
Normal file
49
scm-ui/ui-plugins/src/commands/postinstall.js
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
/* eslint-disable no-console */
|
||||||
const { spawnSync } = require("child_process");
|
const { spawnSync } = require("child_process");
|
||||||
|
|
||||||
const commands = ["plugin", "plugin-watch", "publish", "version"];
|
const commands = ["plugin", "plugin-watch", "publish", "version"];
|
||||||
@@ -15,9 +16,7 @@ const nodeArgs = commandIndex > 0 ? args.slice(0, commandIndex) : [];
|
|||||||
if (commands.includes(command)) {
|
if (commands.includes(command)) {
|
||||||
const result = spawnSync(
|
const result = spawnSync(
|
||||||
"node",
|
"node",
|
||||||
nodeArgs
|
nodeArgs.concat(require.resolve("../src/commands/" + command)).concat(args.slice(commandIndex + 1)),
|
||||||
.concat(require.resolve("../src/commands/" + command))
|
|
||||||
.concat(args.slice(commandIndex + 1)),
|
|
||||||
{ stdio: "inherit" }
|
{ stdio: "inherit" }
|
||||||
);
|
);
|
||||||
if (result.signal) {
|
if (result.signal) {
|
||||||
@@ -38,9 +37,6 @@ if (commands.includes(command)) {
|
|||||||
}
|
}
|
||||||
process.exit(result.status);
|
process.exit(result.status);
|
||||||
} else {
|
} else {
|
||||||
console.log("Unknown script \"" + command + "\".");
|
console.log(`Unknown script "${command}".`);
|
||||||
console.log("Perhaps you need to update react-scripts?");
|
console.log("Perhaps you need to update ui-scripts?");
|
||||||
console.log(
|
|
||||||
"See: https://facebook.github.io/create-react-app/docs/updating-to-new-releases"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -813,6 +813,12 @@ form .field:not(.is-grouped) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// radio
|
||||||
|
//overwrite bulma's default margin
|
||||||
|
.radio + .radio {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
// cursor
|
// cursor
|
||||||
.has-cursor-pointer {
|
.has-cursor-pointer {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
"changesets": {
|
"changesets": {
|
||||||
"errorTitle": "Fehler",
|
"errorTitle": "Fehler",
|
||||||
"errorSubtitle": "Changesets konnten nicht abgerufen werden",
|
"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",
|
"branchSelectorLabel": "Branches",
|
||||||
"collapseDiffs": "Auf-/Zuklappen"
|
"collapseDiffs": "Auf-/Zuklappen"
|
||||||
},
|
},
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
"file-tree": {
|
"file-tree": {
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
"length": "Größe",
|
"length": "Größe",
|
||||||
"lastModified": "Zuletzt bearbeitet",
|
"commitDate": "Commitdatum",
|
||||||
"description": "Beschreibung",
|
"description": "Beschreibung",
|
||||||
"branch": "Branch",
|
"branch": "Branch",
|
||||||
"notYetComputed": "Noch nicht berechnet; Der Wert wird in Kürze aktualisiert",
|
"notYetComputed": "Noch nicht berechnet; Der Wert wird in Kürze aktualisiert",
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
"downloadButton": "Download",
|
"downloadButton": "Download",
|
||||||
"path": "Pfad",
|
"path": "Pfad",
|
||||||
"branch": "Branch",
|
"branch": "Branch",
|
||||||
"lastModified": "Zuletzt bearbeitet",
|
"commitDate": "Commitdatum",
|
||||||
"description": "Beschreibung",
|
"description": "Beschreibung",
|
||||||
"size": "Größe"
|
"size": "Größe"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
"changesets": {
|
"changesets": {
|
||||||
"errorTitle": "Error",
|
"errorTitle": "Error",
|
||||||
"errorSubtitle": "Could not fetch changesets",
|
"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",
|
"branchSelectorLabel": "Branches",
|
||||||
"collapseDiffs": "Collapse"
|
"collapseDiffs": "Collapse"
|
||||||
},
|
},
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
"file-tree": {
|
"file-tree": {
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
"length": "Length",
|
"length": "Length",
|
||||||
"lastModified": "Last modified",
|
"commitDate": "Commit date",
|
||||||
"description": "Description",
|
"description": "Description",
|
||||||
"branch": "Branch",
|
"branch": "Branch",
|
||||||
"notYetComputed": "Not yet computed, will be updated in a short while",
|
"notYetComputed": "Not yet computed, will be updated in a short while",
|
||||||
@@ -111,7 +111,7 @@
|
|||||||
"downloadButton": "Download",
|
"downloadButton": "Download",
|
||||||
"path": "Path",
|
"path": "Path",
|
||||||
"branch": "Branch",
|
"branch": "Branch",
|
||||||
"lastModified": "Last modified",
|
"commitDate": "Commit date",
|
||||||
"description": "Description",
|
"description": "Description",
|
||||||
"size": "Size"
|
"size": "Size"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
"changesets": {
|
"changesets": {
|
||||||
"errorTitle": "Error",
|
"errorTitle": "Error",
|
||||||
"errorSubtitle": "No se han podido recuperar los changesets",
|
"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",
|
"branchSelectorLabel": "Ramas",
|
||||||
"collapseDiffs": "Colapso"
|
"collapseDiffs": "Colapso"
|
||||||
},
|
},
|
||||||
@@ -99,9 +99,11 @@
|
|||||||
"file-tree": {
|
"file-tree": {
|
||||||
"name": "Nombre",
|
"name": "Nombre",
|
||||||
"length": "Longitud",
|
"length": "Longitud",
|
||||||
"lastModified": "Última modificación",
|
"commitDate": "Fecha de cometer",
|
||||||
"description": "Descripción",
|
"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": {
|
"content": {
|
||||||
"historyButton": "Historia",
|
"historyButton": "Historia",
|
||||||
@@ -109,7 +111,7 @@
|
|||||||
"downloadButton": "Descargar",
|
"downloadButton": "Descargar",
|
||||||
"path": "Ruta",
|
"path": "Ruta",
|
||||||
"branch": "Rama",
|
"branch": "Rama",
|
||||||
"lastModified": "Última modificación",
|
"commitDate": "Fecha de cometer",
|
||||||
"description": "Discripción",
|
"description": "Discripción",
|
||||||
"size": "tamaño"
|
"size": "tamaño"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ class Content extends React.Component<Props, State> {
|
|||||||
<td>{fileSize}</td>
|
<td>{fileSize}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{t("sources.content.lastModified")}</td>
|
<td>{t("sources.content.commitDate")}</td>
|
||||||
<td>{date}</td>
|
<td>{date}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { getFailure } from "../../../modules/failure";
|
|||||||
|
|
||||||
export const FETCH_SOURCES = "scm/repos/FETCH_SOURCES";
|
export const FETCH_SOURCES = "scm/repos/FETCH_SOURCES";
|
||||||
export const FETCH_SOURCES_PENDING = `${FETCH_SOURCES}_${types.PENDING_SUFFIX}`;
|
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_SUCCESS = `${FETCH_SOURCES}_${types.SUCCESS_SUFFIX}`;
|
||||||
export const FETCH_SOURCES_FAILURE = `${FETCH_SOURCES}_${types.FAILURE_SUFFIX}`;
|
export const FETCH_SOURCES_FAILURE = `${FETCH_SOURCES}_${types.FAILURE_SUFFIX}`;
|
||||||
|
|
||||||
@@ -61,7 +62,7 @@ export function updateSourcesPending(
|
|||||||
currentSources: any
|
currentSources: any
|
||||||
): Action {
|
): Action {
|
||||||
return {
|
return {
|
||||||
type: "UPDATE_PENDING",
|
type: FETCH_UPDATES_PENDING,
|
||||||
payload: { updatePending: true, sources: currentSources },
|
payload: { updatePending: true, sources: currentSources },
|
||||||
itemId: createItemId(repository, revision, path)
|
itemId: createItemId(repository, revision, path)
|
||||||
};
|
};
|
||||||
@@ -97,7 +98,7 @@ export default function reducer(
|
|||||||
type: "UNKNOWN"
|
type: "UNKNOWN"
|
||||||
}
|
}
|
||||||
): any {
|
): 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 {
|
return {
|
||||||
...state,
|
...state,
|
||||||
[action.itemId]: action.payload
|
[action.itemId]: action.payload
|
||||||
|
|||||||
Reference in New Issue
Block a user