Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■
    pom.xml
    skipped 8 lines
    9 9   <version>1.0.5</version>
    10 10   </parent>
    11 11   <artifactId>server</artifactId>
    12  - <version>4.0.7</version>
     12 + <version>4.0.8</version>
    13 13   <packaging>pom</packaging>
    14 14   <build>
    15 15   <finalName>${project.groupId}.${project.artifactId}-${project.version}</finalName>
    skipped 579 lines
  • ■ ■ ■ ■
    server-core/pom.xml
    skipped 6 lines
    7 7   <parent>
    8 8   <groupId>io.onedev</groupId>
    9 9   <artifactId>server</artifactId>
    10  - <version>4.0.7</version>
     10 + <version>4.0.8</version>
    11 11   </parent>
    12 12   <build>
    13 13   <plugins>
    skipped 307 lines
  • ■ ■ ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/buildspec/job/Job.java
    skipped 1 lines
    2 2  
    3 3  import static io.onedev.server.model.Build.NAME_COMMIT;
    4 4  import static io.onedev.server.model.Build.NAME_JOB;
     5 +import static io.onedev.server.model.Build.NAME_BRANCH;
     6 +import static io.onedev.server.model.Build.NAME_TAG;
     7 +import static io.onedev.server.model.Build.NAME_PULL_REQUEST;
     8 +
    5 9  import static io.onedev.server.search.entity.build.BuildQuery.getRuleName;
    6 10  import static io.onedev.server.search.entity.build.BuildQueryLexer.And;
    7 11  import static io.onedev.server.search.entity.build.BuildQueryLexer.Is;
    skipped 30 lines
    38 42  import io.onedev.server.buildspec.job.paramsupply.ParamSupply;
    39 43  import io.onedev.server.buildspec.job.trigger.JobTrigger;
    40 44  import io.onedev.server.event.ProjectEvent;
     45 +import io.onedev.server.git.GitUtils;
    41 46  import io.onedev.server.model.Project;
     47 +import io.onedev.server.model.PullRequest;
    42 48  import io.onedev.server.util.ComponentContext;
    43 49  import io.onedev.server.util.EditContext;
    44 50  import io.onedev.server.util.criteria.Criteria;
    skipped 435 lines
    480 486   return paramSpecMap;
    481 487   }
    482 488  
    483  - public static String getBuildQuery(ObjectId commitId, String jobName) {
    484  - return ""
     489 + public static String getBuildQuery(ObjectId commitId, String jobName,
     490 + @Nullable String refName, @Nullable PullRequest request) {
     491 + String query = ""
    485 492   + Criteria.quote(NAME_COMMIT) + " " + getRuleName(Is) + " " + Criteria.quote(commitId.name())
    486 493   + " " + getRuleName(And) + " "
    487 494   + Criteria.quote(NAME_JOB) + " " + getRuleName(Is) + " " + Criteria.quote(jobName);
     495 + if (request != null) {
     496 + query = query
     497 + + " " + getRuleName(And) + " "
     498 + + Criteria.quote(NAME_PULL_REQUEST) + " " + getRuleName(Is) + " " + Criteria.quote("#" + request.getNumber());
     499 + }
     500 + if (refName != null) {
     501 + String branch = GitUtils.ref2branch(refName);
     502 + if (branch != null) {
     503 + query = query
     504 + + " " + getRuleName(And) + " "
     505 + + Criteria.quote(NAME_BRANCH) + " " + getRuleName(Is) + " " + Criteria.quote(branch);
     506 + }
     507 + String tag = GitUtils.ref2tag(refName);
     508 + if (tag != null) {
     509 + query = query
     510 + + " " + getRuleName(And) + " "
     511 + + Criteria.quote(NAME_TAG) + " " + getRuleName(Is) + " " + Criteria.quote(tag);
     512 + }
     513 + }
     514 + return query;
    488 515   }
    489 516  
    490 517   public static List<String> getChoices() {
    skipped 32 lines
  • ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/buildspec/job/SubmitReason.java
    skipped 5 lines
    6 6   
    7 7  public interface SubmitReason {
    8 8   
    9  - @Nullable
    10 9   String getRefName();
    11 10  
     11 + @Nullable
    12 12   PullRequest getPullRequest();
    13 13  
    14 14   String getDescription();
    skipped 3 lines
  • ■ ■ ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/buildspec/job/trigger/DependencyFinishedTrigger.java
    skipped 36 lines
    37 37  
    38 38   @Override
    39 39   public String getRefName() {
    40  - return null;
     40 + return build.getRefName();
    41 41   }
    42 42  
    43 43   @Override
    44 44   public PullRequest getPullRequest() {
    45  - return null;
     45 + return build.getRequest();
    46 46   }
    47 47  
    48 48   @Override
    skipped 18 lines
  • ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/buildspec/job/trigger/PullRequestTrigger.java
    skipped 94 lines
    95 95  
    96 96   @Override
    97 97   public String getRefName() {
    98  - return null;
     98 + return request.getMergeRef();
    99 99   }
    100 100  
    101 101   @Override
    skipped 34 lines
  • ■ ■ ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/entitymanager/BuildManager.java
    skipped 8 lines
    9 9  import org.eclipse.jgit.lib.ObjectId;
    10 10   
    11 11  import io.onedev.server.model.Build;
    12  -import io.onedev.server.model.Build.Status;
    13 12  import io.onedev.server.model.Project;
    14 13  import io.onedev.server.model.PullRequest;
    15 14  import io.onedev.server.persistence.dao.EntityManager;
    16 15  import io.onedev.server.search.entity.EntityCriteria;
    17 16  import io.onedev.server.search.entity.EntityQuery;
    18 17  import io.onedev.server.util.ProjectScopedNumber;
     18 +import io.onedev.server.util.StatusInfo;
    19 19   
    20 20  public interface BuildManager extends EntityManager<Build> {
    21 21   
    22  - @Nullable
    23  - Build find(Project project, long number);
     22 + @Nullable
     23 + Build find(Project project, long number);
    24 24   
    25  - @Nullable
    26  - Build find(String buildFQN);
     25 + @Nullable
     26 + Build find(String buildFQN);
    27 27   
    28  - @Nullable
    29  - Build find(ProjectScopedNumber buildFQN);
     28 + @Nullable
     29 + Build find(ProjectScopedNumber buildFQN);
    30 30   
    31  - @Nullable
     31 + @Nullable
    32 32   Build findStreamPrevious(Build build, @Nullable Build.Status status);
    33 33   
    34 34   Collection<Long> queryNumbersOfStreamPrevious(Build build, @Nullable Build.Status status, int limit);
    35 35   
    36  - Collection<Build> query(Project project, ObjectId commitId, @Nullable String jobName,
    37  - @Nullable String refName, @Nullable PullRequest request, Map<String, List<String>> params);
     36 + Collection<Build> query(Project project, ObjectId commitId, @Nullable String jobName, @Nullable String refName,
     37 + @Nullable PullRequest request, Map<String, List<String>> params);
    38 38   
    39 39   Collection<Build> query(Project project, ObjectId commitId, @Nullable String jobName);
    40 40   
    41 41   Collection<Build> query(Project project, ObjectId commitId);
    42 42   
    43  - Map<ObjectId, Map<String, Status>> queryStatus(Project project, Collection<ObjectId> commitIds);
     43 + Map<ObjectId, Map<String, Collection<StatusInfo>>> queryStatus(Project project, Collection<ObjectId> commitIds);
    44 44   
    45 45   void create(Build build);
    46 46   
    skipped 24 lines
  • ■ ■ ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/entitymanager/impl/DefaultBuildManager.java
    skipped 79 lines
    80 80  import io.onedev.server.security.SecurityUtils;
    81 81  import io.onedev.server.storage.StorageManager;
    82 82  import io.onedev.server.util.ProjectScopedNumber;
     83 +import io.onedev.server.util.StatusInfo;
    83 84  import io.onedev.server.util.facade.BuildFacade;
    84 85  import io.onedev.server.util.match.StringMatcher;
    85 86  import io.onedev.server.util.patternset.PatternSet;
    skipped 186 lines
    272 273   
    273 274   if (request != null)
    274 275   predicates.add(builder.equal(root.get(Build.PROP_PULL_REQUEST), request));
     276 + else
     277 + predicates.add(builder.isNull(root.get(Build.PROP_PULL_REQUEST)));
    275 278  
    276 279   for (Map.Entry<String, List<String>> entry: params.entrySet()) {
    277 280   if (!entry.getValue().isEmpty()) {
    skipped 225 lines
    503 506  
    504 507   @Sessional
    505 508   @Override
    506  - public Map<ObjectId, Map<String, Status>> queryStatus(Project project, Collection<ObjectId> commitIds) {
    507  - Map<ObjectId, Map<String, Collection<Status>>> commitStatuses = new HashMap<>();
     509 + public Map<ObjectId, Map<String, Collection<StatusInfo>>> queryStatus(Project project, Collection<ObjectId> commitIds) {
     510 + Map<ObjectId, Map<String, Collection<StatusInfo>>> commitStatuses = new HashMap<>();
    508 511  
    509 512   Collection<ObjectId> batch = new HashSet<>();
    510 513   for (ObjectId commitId: commitIds) {
    skipped 5 lines
    516 519   }
    517 520   if (!batch.isEmpty())
    518 521   fillStatus(project, batch, commitStatuses);
    519  - Map<ObjectId, Map<String, Status>> overallCommitStatuses = new HashMap<>();
    520  - for (Map.Entry<ObjectId, Map<String, Collection<Status>>> entry: commitStatuses.entrySet()) {
    521  - Map<String, Status> jobOverallStatuses = new HashMap<>();
    522  - for (Map.Entry<String, Collection<Status>> entry2: entry.getValue().entrySet())
    523  - jobOverallStatuses.put(entry2.getKey(), Status.getOverallStatus(entry2.getValue()));
    524  - overallCommitStatuses.put(entry.getKey(), jobOverallStatuses);
    525  - }
    526 522   for (ObjectId commitId: commitIds) {
    527  - if (!overallCommitStatuses.containsKey(commitId))
    528  - overallCommitStatuses.put(commitId, new HashMap<>());
     523 + if (!commitStatuses.containsKey(commitId))
     524 + commitStatuses.put(commitId, new HashMap<>());
    529 525   }
    530  - return overallCommitStatuses;
     526 + return commitStatuses;
    531 527   }
    532 528  
    533 529   @SuppressWarnings("unchecked")
    534 530   private void fillStatus(Project project, Collection<ObjectId> commitIds,
    535  - Map<ObjectId, Map<String, Collection<Status>>> commitStatuses) {
    536  - Query<?> query = getSession().createQuery("select commitHash, jobName, status from Build "
     531 + Map<ObjectId, Map<String, Collection<StatusInfo>>> commitStatuses) {
     532 + Query<?> query = getSession().createQuery("select commitHash, jobName, status, refName, request.id from Build "
    537 533   + "where project=:project and commitHash in :commitHashes");
    538 534   query.setParameter("project", project);
    539 535   query.setParameter("commitHashes", commitIds.stream().map(it->it.name()).collect(Collectors.toList()));
    skipped 1 lines
    541 537   ObjectId commitId = ObjectId.fromString((String) row[0]);
    542 538   String jobName = (String) row[1];
    543 539   Status status = (Status) row[2];
    544  - Map<String, Collection<Status>> commitStatus = commitStatuses.get(commitId);
     540 + String refName = (String) row[3];
     541 + Long requestId = (Long) row[4];
     542 +
     543 + Map<String, Collection<StatusInfo>> commitStatus = commitStatuses.get(commitId);
    545 544   if (commitStatus == null) {
    546 545   commitStatus = new HashMap<>();
    547 546   commitStatuses.put(commitId, commitStatus);
    548 547   }
    549  - Collection<Status> jobStatus = commitStatus.get(jobName);
     548 + Collection<StatusInfo> jobStatus = commitStatus.get(jobName);
    550 549   if (jobStatus == null) {
    551 550   jobStatus = new HashSet<>();
    552 551   commitStatus.put(jobName, jobStatus);
    553 552   }
    554  - jobStatus.add(status);
     553 + jobStatus.add(new StatusInfo(status, requestId, refName));
    555 554   }
    556 555   }
    557 556  
    skipped 321 lines
  • ■ ■ ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/migration/DataMigrator.java
    skipped 2286 lines
    2287 2287   }
    2288 2288   }
    2289 2289  
     2290 + // migrate to 4.0.8
     2291 + private void migrate47(File dataDir, Stack<Integer> versions) {
     2292 + for (File file: dataDir.listFiles()) {
     2293 + if (file.getName().startsWith("Builds.xml")) {
     2294 + VersionedXmlDoc dom = VersionedXmlDoc.fromFile(file);
     2295 + for (Element element: dom.getRootElement().elements()) {
     2296 + Element refNameElement = element.element("refName");
     2297 + if (refNameElement == null)
     2298 + element.addElement("refName").setText("unknown");
     2299 + }
     2300 + dom.writeToFile(file, false);
     2301 + }
     2302 + }
     2303 + }
     2304 +
    2290 2305  }
    2291 2306   
  • ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/model/Build.java
    skipped 273 lines
    274 274   @Column(nullable=false)
    275 275   private String jobName;
    276 276  
     277 + @Column(nullable=false)
    277 278   private String refName;
    278 279  
    279 280   private String version;
    skipped 276 lines
    556 557   this.errorMessage = errorMessage;
    557 558   }
    558 559   
    559  - @Nullable
    560 560   public String getRefName() {
    561 561   return refName;
    562 562   }
    skipped 505 lines
  • ■ ■ ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/model/Project.java
    skipped 14 lines
    15 15  import java.util.Iterator;
    16 16  import java.util.List;
    17 17  import java.util.Map;
     18 +import java.util.Objects;
    18 19  import java.util.Set;
    19 20  import java.util.Stack;
    20 21  import java.util.concurrent.ConcurrentHashMap;
    skipped 88 lines
    109 110  import io.onedev.server.storage.StorageManager;
    110 111  import io.onedev.server.util.CollectionUtils;
    111 112  import io.onedev.server.util.ComponentContext;
     113 +import io.onedev.server.util.StatusInfo;
    112 114  import io.onedev.server.util.jackson.DefaultView;
    113 115  import io.onedev.server.util.match.Matcher;
    114 116  import io.onedev.server.util.match.PathMatcher;
    skipped 180 lines
    295 297  
    296 298   private transient Map<ObjectId, Optional<BuildSpec>> buildSpecCache;
    297 299  
    298  - private transient Map<ObjectId, Map<String, Status>> commitStatusCache;
     300 + private transient Map<ObjectId, Map<String, Collection<StatusInfo>>> commitStatusCache;
    299 301  
    300 302   private transient Map<ObjectId, Optional<RevCommit>> commitCache;
    301 303  
    skipped 357 lines
    659 661   objectIdCache.put(revision, Optional.fromNullable(objectId));
    660 662   }
    661 663   
    662  - public Map<String, Status> getCommitStatus(ObjectId commitId) {
    663  - Map<String, Status> commitStatus = getCommitStatusCache().get(commitId);
    664  - if (commitStatus == null) {
     664 + public Map<String, Status> getCommitStatus(ObjectId commitId,
     665 + @Nullable PullRequest request, @Nullable String refName) {
     666 + Map<String, Collection<StatusInfo>> commitStatusInfos = getCommitStatusCache().get(commitId);
     667 + if (commitStatusInfos == null) {
    665 668   BuildManager buildManager = OneDev.getInstance(BuildManager.class);
    666  - commitStatus = buildManager.queryStatus(this, Sets.newHashSet(commitId)).get(commitId);
    667  - getCommitStatusCache().put(commitId, Preconditions.checkNotNull(commitStatus));
     669 + commitStatusInfos = buildManager.queryStatus(this, Sets.newHashSet(commitId)).get(commitId);
     670 + getCommitStatusCache().put(commitId, Preconditions.checkNotNull(commitStatusInfos));
     671 + }
     672 + Map<String, Status> commitStatus = new HashMap<>();
     673 + for (Map.Entry<String, Collection<StatusInfo>> entry: commitStatusInfos.entrySet()) {
     674 + Collection<Status> statuses = new ArrayList<>();
     675 + for (StatusInfo statusInfo: entry.getValue()) {
     676 + if ((refName == null || refName.equals(statusInfo.getRefName()))
     677 + && Objects.equals(PullRequest.idOf(request), statusInfo.getRequestId())) {
     678 + statuses.add(statusInfo.getStatus());
     679 + }
     680 + }
     681 + commitStatus.put(entry.getKey(), Status.getOverallStatus(statuses));
    668 682   }
    669 683   return commitStatus;
    670 684   }
    671 685  
    672  - private Map<ObjectId, Map<String, Status>> getCommitStatusCache() {
     686 + private Map<ObjectId, Map<String, Collection<StatusInfo>>> getCommitStatusCache() {
    673 687   if (commitStatusCache == null)
    674 688   commitStatusCache = new HashMap<>();
    675 689   return commitStatusCache;
    676 690   }
    677 691  
    678  - public void cacheCommitStatus(Map<ObjectId, Map<String, Status>> commitStatuses) {
     692 + public void cacheCommitStatus(Map<ObjectId, Map<String, Collection<StatusInfo>>> commitStatuses) {
    679 693   getCommitStatusCache().putAll(commitStatuses);
    680 694   }
    681 695  
    skipped 761 lines
  • ■ ■ ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/security/realm/PasswordAuthorizingRealm.java
    skipped 9 lines
    10 10  import org.apache.shiro.authc.AuthenticationException;
    11 11  import org.apache.shiro.authc.AuthenticationInfo;
    12 12  import org.apache.shiro.authc.AuthenticationToken;
     13 +import org.apache.shiro.authc.UnknownAccountException;
    13 14  import org.apache.shiro.authc.UsernamePasswordToken;
    14 15  import org.apache.shiro.authc.credential.PasswordMatcher;
    15 16  import org.apache.shiro.authc.credential.PasswordService;
    skipped 104 lines
    120 121   + "' has already been used by another account");
    121 122   }
    122 123   user = newUser(userName, authenticated, authenticator.getDefaultGroup());
     124 + } else {
     125 + throw new UnknownAccountException("Unable to find account data for token [" + token + "] in realm [" + this + "]");
    123 126   }
    124 127   } else if (user.getPassword().equals(User.EXTERNAL_MANAGED)) {
    125 128   if (user.getSsoInfo().getConnector() != null) {
    skipped 33 lines
  • ■ ■ ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/util/StatusInfo.java
     1 +package io.onedev.server.util;
     2 + 
     3 +import java.io.Serializable;
     4 + 
     5 +import javax.annotation.Nullable;
     6 + 
     7 +import io.onedev.server.model.Build;
     8 + 
     9 +public class StatusInfo implements Serializable {
     10 + 
     11 + private static final long serialVersionUID = 1L;
     12 + 
     13 + private final Long requestId;
     14 +
     15 + private final String refName;
     16 +
     17 + private final Build.Status status;
     18 +
     19 + public StatusInfo(Build.Status status, @Nullable Long requestId, @Nullable String refName) {
     20 + this.status = status;
     21 + this.requestId = requestId;
     22 + this.refName = refName;
     23 + }
     24 + 
     25 + @Nullable
     26 + public Long getRequestId() {
     27 + return requestId;
     28 + }
     29 + 
     30 + @Nullable
     31 + public String getRefName() {
     32 + return refName;
     33 + }
     34 + 
     35 + public Build.Status getStatus() {
     36 + return status;
     37 + }
     38 +
     39 +}
     40 + 
  • ■ ■ ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/web/component/build/side/BuildSidePanel.java
    skipped 75 lines
    76 76  
    77 77   add(general);
    78 78   
    79  - if (getBuild().getRefName() != null) {
    80  - String branch = GitUtils.ref2branch(getBuild().getRefName());
    81  - general.add(new Label("branch", branch).setVisible(branch != null));
    82  - } else {
    83  - general.add(new WebMarkupContainer("branch").setVisible(false));
    84  - }
     79 + String branch = getBuild().getBranch();
     80 + general.add(new Label("branch", branch).setVisible(branch != null));
    85 81  
    86  - if (getBuild().getRefName() != null) {
    87  - String tag = GitUtils.ref2tag(getBuild().getRefName());
    88  - general.add(new Label("tag", tag).setVisible(tag != null));
    89  - } else {
    90  - general.add(new WebMarkupContainer("tag").setVisible(false));
    91  - }
     82 + String tag = getBuild().getTag();
     83 + general.add(new Label("tag", tag).setVisible(tag != null));
    92 84  
    93 85   CommitDetailPage.State commitState = new CommitDetailPage.State();
    94 86   commitState.revision = getBuild().getCommitHash();
    skipped 237 lines
  • ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/web/component/commit/status/CommitStatusPanel.java
    skipped 61 lines
    62 62   
    63 63   @Override
    64 64   protected Status load() {
    65  - return Status.getOverallStatus(getProject().getCommitStatus(commitId).values());
     65 + return Status.getOverallStatus(getProject().getCommitStatus(commitId, getPullRequest(), refName).values());
    66 66   }
    67 67  
    68 68   };
    skipped 104 lines
  • ■ ■ ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/web/component/job/BuildOptionContentPanel.html
    skipped 7 lines
    8 8   <wicket:enclosure child="refNames">
    9 9   <div class="form-group">
    10 10   <label class="control-label">Build On Behalf Of</label>
    11  - <div class="d-flex flex-wrap mb-3">
     11 + <div class="d-flex flex-wrap">
    12 12   <label wicket:id="refNames" class="checkbox flex-shrink-0 mr-3 mb-2">
    13 13   <input wicket:id="check" type="checkbox"> <wicket:container wicket:id="label"></wicket:container>
    14 14   </label>
    15  - <div class="form-text text-muted">For each selected branch/tag, a separate build will be
    16  - generated with branch/tag set to corresponding value</div>
    17 15   </div>
     16 + <div wicket:id="refNamesError"></div>
     17 + <div class="form-text text-muted">For each selected branch/tag, a separate build will be
     18 + generated with branch/tag set to corresponding value</div>
    18 19   </div>
    19 20   </wicket:enclosure>
    20 21   <div wicket:id="paramEditor"></div>
    skipped 7 lines
  • ■ ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/web/component/job/BuildOptionContentPanel.java
    skipped 7 lines
    8 8  import org.apache.wicket.ajax.AjaxRequestTarget;
    9 9  import org.apache.wicket.ajax.markup.html.AjaxLink;
    10 10  import org.apache.wicket.ajax.markup.html.form.AjaxButton;
     11 +import org.apache.wicket.feedback.FencedFeedbackPanel;
    11 12  import org.apache.wicket.markup.html.basic.Label;
    12 13  import org.apache.wicket.markup.html.form.CheckBox;
    13 14  import org.apache.wicket.markup.html.form.Form;
    skipped 39 lines
    53 54   };
    54 55   form.setOutputMarkupId(true);
    55 56  
    56  - form.add(new ListView<String>("refNames", refNames) {
     57 + ListView<String> refNamesView;
     58 + form.add(refNamesView = new ListView<String>("refNames", refNames) {
    57 59  
    58 60   @Override
    59 61   protected void populateItem(ListItem<String> item) {
    skipped 34 lines
    94 96  
    95 97   });
    96 98  
     99 + form.add(new FencedFeedbackPanel("refNamesError", refNamesView));
     100 +
    97 101   form.add(BeanContext.edit("paramEditor", paramBean));
    98 102  
    99 103   form.add(new AjaxButton("ok") {
    skipped 1 lines
    101 105   @Override
    102 106   protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
    103 107   super.onSubmit(target, form);
    104  - onSave(target, selectedRefNames, paramBean);
     108 + if (selectedRefNames.isEmpty()) {
     109 + refNamesView.error("At least one branch or tag should be selected");
     110 + target.add(form);
     111 + } else {
     112 + onSave(target, selectedRefNames, paramBean);
     113 + }
    105 114   }
    106 115  
    107 116   });
    skipped 25 lines
  • ■ ■ ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/web/component/job/RunJobLink.java
    skipped 9 lines
    10 10   
    11 11  import javax.annotation.Nullable;
    12 12   
     13 +import org.apache.wicket.Component;
    13 14  import org.apache.wicket.ajax.AjaxRequestTarget;
    14 15  import org.apache.wicket.ajax.markup.html.AjaxLink;
     16 +import org.apache.wicket.markup.html.basic.Label;
    15 17  import org.eclipse.jgit.lib.ObjectId;
    16 18   
    17 19  import com.google.common.base.Preconditions;
    skipped 15 lines
    33 35  import io.onedev.server.security.SecurityUtils;
    34 36  import io.onedev.server.util.script.identity.JobIdentity;
    35 37  import io.onedev.server.util.script.identity.ScriptIdentity;
     38 +import io.onedev.server.web.component.modal.message.MessageModal;
    36 39  import io.onedev.server.web.page.project.builds.detail.dashboard.BuildDashboardPage;
    37 40  import io.onedev.server.web.page.project.builds.detail.log.BuildLogPage;
    38 41   
    skipped 35 lines
    74 77  
    75 78   if (refName != null) {
    76 79   refNames = Lists.newArrayList(refName);
     80 + } else if (getPullRequest() != null) {
     81 + refNames = Lists.newArrayList(getPullRequest().getMergeRef());
    77 82   } else {
    78 83   refNames = refs.stream()
    79 84   .filter(it->descendants.contains(it.getPeeledObj()))
    skipped 1 lines
    81 86   .collect(Collectors.toList());
    82 87   }
    83 88   
    84  - Job job = Preconditions.checkNotNull(buildSpec.getJobMap().get(jobName));
    85  - if (refNames.size() > 1 || !job.getParamSpecs().isEmpty()) {
    86  - Serializable paramBean;
    87  - try {
    88  - paramBean = ParamSupply.defineBeanClass(job.getParamSpecs()).newInstance();
    89  - } catch (InstantiationException | IllegalAccessException e) {
    90  - throw new RuntimeException(e);
    91  - }
     89 + if (!refNames.isEmpty()) {
     90 + Job job = Preconditions.checkNotNull(buildSpec.getJobMap().get(jobName));
     91 + if (refNames.size() > 1 || !job.getParamSpecs().isEmpty()) {
     92 + Serializable paramBean;
     93 + try {
     94 + paramBean = ParamSupply.defineBeanClass(job.getParamSpecs()).newInstance();
     95 + } catch (InstantiationException | IllegalAccessException e) {
     96 + throw new RuntimeException(e);
     97 + }
    92 98  
    93  - new BuildOptionModalPanel(target, refNames, paramBean) {
     99 + new BuildOptionModalPanel(target, refNames, paramBean) {
    94 100   
    95  - @Override
    96  - protected void onSave(AjaxRequestTarget target, Collection<String> selectedRefNames,
    97  - Serializable populatedParamBean) {
    98  - Map<String, List<String>> paramMap = ParamSupply.getParamMap(
    99  - job, populatedParamBean, job.getParamSpecMap().keySet());
    100  - List<Build> builds = new ArrayList<>();
    101  - if (selectedRefNames.isEmpty())
    102  - selectedRefNames.add(null);
    103  - for (String refName: selectedRefNames) {
    104  - SubmitReason reason = new SubmitReason() {
     101 + @Override
     102 + protected void onSave(AjaxRequestTarget target, Collection<String> selectedRefNames,
     103 + Serializable populatedParamBean) {
     104 + Map<String, List<String>> paramMap = ParamSupply.getParamMap(
     105 + job, populatedParamBean, job.getParamSpecMap().keySet());
     106 + List<Build> builds = new ArrayList<>();
     107 + for (String refName: selectedRefNames) {
     108 + SubmitReason reason = new SubmitReason() {
    105 109   
    106  - @Override
    107  - public String getRefName() {
    108  - return refName;
    109  - }
     110 + @Override
     111 + public String getRefName() {
     112 + return refName;
     113 + }
    110 114   
    111  - @Override
    112  - public PullRequest getPullRequest() {
    113  - return RunJobLink.this.getPullRequest();
    114  - }
     115 + @Override
     116 + public PullRequest getPullRequest() {
     117 + return RunJobLink.this.getPullRequest();
     118 + }
    115 119   
    116  - @Override
    117  - public String getDescription() {
    118  - return "Submitted manually";
    119  - }
     120 + @Override
     121 + public String getDescription() {
     122 + return "Submitted manually";
     123 + }
    120 124  
    121  - };
    122  - builds.add(getJobManager().submit(getProject(), commitId, job.getName(),
    123  - paramMap, reason));
     125 + };
     126 + builds.add(getJobManager().submit(getProject(), commitId, job.getName(),
     127 + paramMap, reason));
     128 + }
     129 + if (builds.size() == 1)
     130 + setResponsePage(BuildDashboardPage.class, BuildDashboardPage.paramsOf(builds.iterator().next()));
     131 + else
     132 + close();
    124 133   }
    125  - if (builds.size() == 1)
    126  - setResponsePage(BuildDashboardPage.class, BuildDashboardPage.paramsOf(builds.iterator().next()));
    127  - else
    128  - close();
    129  - }
    130 134   
    131  - @Override
    132  - public List<String> getInputNames() {
    133  - return new ArrayList<>(job.getParamSpecMap().keySet());
    134  - }
     135 + @Override
     136 + public List<String> getInputNames() {
     137 + return new ArrayList<>(job.getParamSpecMap().keySet());
     138 + }
    135 139   
    136  - @Override
    137  - public ParamSpec getInputSpec(String paramName) {
    138  - return Preconditions.checkNotNull(job.getParamSpecMap().get(paramName));
    139  - }
     140 + @Override
     141 + public ParamSpec getInputSpec(String paramName) {
     142 + return Preconditions.checkNotNull(job.getParamSpecMap().get(paramName));
     143 + }
    140 144   
    141  - @Override
    142  - public ScriptIdentity getScriptIdentity() {
    143  - return new JobIdentity(getProject(), commitId);
    144  - }
     145 + @Override
     146 + public ScriptIdentity getScriptIdentity() {
     147 + return new JobIdentity(getProject(), commitId);
     148 + }
    145 149   
    146  - };
    147  - } else {
    148  - SubmitReason reason = new SubmitReason() {
     150 + };
     151 + } else {
     152 + SubmitReason reason = new SubmitReason() {
    149 153   
    150  - @Override
    151  - public String getRefName() {
    152  - if (refNames.isEmpty())
    153  - return null;
    154  - else
     154 + @Override
     155 + public String getRefName() {
    155 156   return refNames.iterator().next();
    156  - }
     157 + }
     158 + 
     159 + @Override
     160 + public PullRequest getPullRequest() {
     161 + return RunJobLink.this.getPullRequest();
     162 + }
     163 + 
     164 + @Override
     165 + public String getDescription() {
     166 + return "Submitted manually";
     167 + }
    157 168  
    158  - @Override
    159  - public PullRequest getPullRequest() {
    160  - return RunJobLink.this.getPullRequest();
    161  - }
     169 + };
     170 + Build build = getJobManager().submit(getProject(), commitId, job.getName(),
     171 + new HashMap<>(), reason);
     172 + setResponsePage(BuildLogPage.class, BuildLogPage.paramsOf(build));
     173 + }
     174 + } else {
     175 + new MessageModal(target) {
    162 176   
    163 177   @Override
    164  - public String getDescription() {
    165  - return "Submitted manually";
     178 + protected Component newMessageContent(String componentId) {
     179 + return new Label(componentId, "No refs to build on behalf of");
    166 180   }
    167 181  
    168 182   };
    169  - Build build = getJobManager().submit(getProject(), commitId, job.getName(),
    170  - new HashMap<>(), reason);
    171  - setResponsePage(BuildLogPage.class, BuildLogPage.paramsOf(build));
    172 183   }
    173 184   }
    174 185  
    skipped 12 lines
  • ■ ■ ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/web/component/job/joblist/JobListPanel.html
    skipped 1 lines
    2 2   <div class="job-list">
    3 3   <div wicket:id="jobs" class="job">
    4 4   <div class="head text-nowrap d-flex align-items-center p-3">
    5  - <a wicket:id="name" class="name"><b wicket:id="label"></b></a>
    6  - <a wicket:id="showInList" class="ml-2" title="Show in build list"><wicket:svg href="unordered-list" class="icon"></wicket:svg></a>
    7  - <a wicket:id="run" class="run ml-2" title="Run this job"><wicket:svg href="play" class="icon"></wicket:svg></a>
     5 + <a wicket:id="name" class="name d-flex align-items-center"><b wicket:id="label"></b></a>
     6 + <a wicket:id="showInList" class="ml-2 d-flex align-items-center" title="Show in build list"><wicket:svg href="unordered-list" class="icon"></wicket:svg></a>
     7 + <a wicket:id="run" class="run ml-2 d-flex align-items-center" title="Run this job"><wicket:svg href="play" class="icon"></wicket:svg></a>
    8 8   </div>
    9 9   <div class="body">
    10 10   <div wicket:id="detail"></div>
    skipped 5 lines
  • ■ ■ ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/web/component/job/joblist/JobListPanel.java
    skipped 2 lines
    3 3  import java.util.ArrayList;
    4 4  import java.util.Collection;
    5 5  import java.util.Comparator;
     6 +import java.util.HashMap;
    6 7  import java.util.List;
    7 8   
    8 9  import javax.annotation.Nullable;
    skipped 83 lines
    92 93   add(jobsView);
    93 94   for (Job job: accessibleJobsModel.getObject()) {
    94 95   WebMarkupContainer jobItem = new WebMarkupContainer(jobsView.newChildId());
    95  - Status status = getProject().getCommitStatus(commitId).get(job.getName());
     96 + Status status = getProject().getCommitStatus(commitId, getPullRequest(), refName).get(job.getName());
    96 97  
    97 98   Link<Void> defLink = new JobDefLink("name", commitId, job.getName()) {
    98 99   
    skipped 27 lines
    126 127   });
    127 128  
    128 129   jobItem.add(new BookmarkablePageLink<Void>("showInList", ProjectBuildsPage.class,
    129  - ProjectBuildsPage.paramsOf(getProject(), Job.getBuildQuery(commitId, job.getName()), 0)) {
     130 + ProjectBuildsPage.paramsOf(getProject(), Job.getBuildQuery(commitId, job.getName(), refName, getPullRequest()), 0)) {
    130 131  
    131 132   @Override
    132 133   protected void onConfigure() {
    skipped 8 lines
    141 142   @Override
    142 143   protected List<Build> load() {
    143 144   BuildManager buildManager = OneDev.getInstance(BuildManager.class);
    144  - List<Build> builds = new ArrayList<>(buildManager.query(getProject(), commitId, job.getName()));
     145 + List<Build> builds = new ArrayList<>(buildManager.query(getProject(), commitId, job.getName(),
     146 + refName, getPullRequest(), new HashMap<>()));
    145 147   builds.sort(Comparator.comparing(Build::getNumber));
    146 148   return builds;
    147 149   }
    skipped 47 lines
  • ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/web/page/base/base.css
    skipped 215 lines
    216 216   display: none;
    217 217  }
    218 218  .clearable-wrapper input.clearable {
    219  - padding-right: 22px;
     219 + padding-right: 30px;
    220 220  }
    221 221  a.input-clear {
    222 222   font-family: sans-serif;
    skipped 335 lines
  • ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/web/page/project/NewProjectPage.html
    1 1  <wicket:extend>
    2  - <div class="card new-project">
     2 + <div class="card new-project m-2 m-sm-5">
    3 3   <div class="card-body">
    4 4   <form wicket:id="form" class="leave-confirm">
    5 5   <div wicket:id="editor" class="mb-4"></div>
    skipped 5 lines
  • ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/web/page/project/blob/ProjectBlobPage.java
    skipped 746 lines
    747 747  
    748 748   @Override
    749 749   protected PullRequest getPullRequest() {
    750  - return ProjectBlobPage.this.getPullRequest();
     750 + return null;
    751 751   }
    752 752  
    753 753   };
    skipped 746 lines
  • ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/web/page/project/builds/detail/BuildDetailPage.html
    skipped 18 lines
    19 19   </div>
    20 20   <div class="card-body d-flex flex-grow-1 position-relative">
    21 21   <div class="main flex-grow-1 d-flex flex-column">
    22  - <pre wicket:id="errorMessage" class="error-message alert alert-notice alert-light-danger overflow-auto mb-4 flex-shrink-0 p-3"></pre>
     22 + <pre wicket:id="errorMessage" class="error-message alert alert-notice alert-light-danger overflow-auto mb-4 flex-shrink-0 p-3 text-break"></pre>
    23 23   <ul wicket:id="buildTabs" class="tabs nav nav-tabs nav nav-tabs-line nav-bold mb-5 flex-shrink-0"></ul>
    24 24   <wicket:child></wicket:child>
    25 25   </div>
    skipped 10 lines
  • ■ ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/web/page/project/commits/CommitDetailPage.java
    skipped 50 lines
    51 51  import io.onedev.server.entitymanager.BuildManager;
    52 52  import io.onedev.server.entitymanager.CodeCommentManager;
    53 53  import io.onedev.server.entitymanager.CodeCommentReplyManager;
    54  -import io.onedev.server.entitymanager.PullRequestManager;
    55 54  import io.onedev.server.git.BlobIdent;
    56 55  import io.onedev.server.git.GitUtils;
    57 56  import io.onedev.server.git.RefInfo;
    skipped 48 lines
    106 105  
    107 106   private static final String PARAM_MARK = "mark";
    108 107  
    109  - private static final String PARAM_REQUEST = "request";
    110  -
    111 108   private State state;
    112 109  
    113 110   private ObjectId resolvedRevision;
    skipped 39 lines
    153 150   state.pathFilter = params.get(PARAM_PATH_FILTER).toString();
    154 151   state.blameFile = params.get(PARAM_BLAME_FILE).toString();
    155 152   state.commentId = params.get(PARAM_COMMENT).toOptionalLong();
    156  - state.requestId = params.get(PARAM_REQUEST).toOptionalLong();
    157 153   state.mark = Mark.fromString(params.get(PARAM_MARK).toString());
    158 154  
    159 155   resolvedRevision = getProject().getRevCommit(state.revision, true).copy();
    skipped 171 lines
    331 327   @Override
    332 328   protected Component newListLink(String componentId) {
    333 329   return new BookmarkablePageLink<Void>(componentId, ProjectBuildsPage.class,
    334  - ProjectBuildsPage.paramsOf(getProject(), Job.getBuildQuery(commitId, job.getName()), 0)) {
     330 + ProjectBuildsPage.paramsOf(getProject(), Job.getBuildQuery(commitId, job.getName(), null, null), 0)) {
    335 331  
    336 332   @Override
    337 333   protected void onConfigure() {
    skipped 12 lines
    350 346   super.onComponentTag(tag);
    351 347  
    352 348   String cssClasses = "btn btn-outline-secondary";
    353  - Build.Status status = getProject().getCommitStatus(commitId).get(job.getName());
     349 + Build.Status status = getProject().getCommitStatus(commitId, null, null).get(job.getName());
    354 350   String title;
    355 351   if (status != null) {
    356 352   if (status != Status.SUCCESSFUL)
    skipped 14 lines
    371 367   
    372 368   @Override
    373 369   protected Status load() {
    374  - return getProject().getCommitStatus(commitId).get(job.getName());
     370 + return getProject().getCommitStatus(commitId, null, null).get(job.getName());
    375 371   }
    376 372  
    377 373   }));
    skipped 26 lines
    404 400   
    405 401   @Override
    406 402   protected PullRequest getPullRequest() {
    407  - if (state.requestId != null)
    408  - return OneDev.getInstance(PullRequestManager.class).load(state.requestId);
    409  - else
    410  - return null;
     403 + return null;
    411 404   }
    412 405  
    413 406   });
    skipped 188 lines
    602 595   params.set(PARAM_BLAME_FILE, state.blameFile);
    603 596   if (state.commentId != null)
    604 597   params.set(PARAM_COMMENT, state.commentId);
    605  - if (state.requestId != null)
    606  - params.set(PARAM_REQUEST, state.requestId);
    607 598   if (state.mark != null)
    608 599   params.set(PARAM_MARK, state.mark.toString());
    609 600   return params;
    skipped 29 lines
    639 630  
    640 631   @Nullable
    641 632   public Long commentId;
    642  -
    643  - @Nullable
    644  - public Long requestId;
    645 633  
    646 634   public WhitespaceOption whitespaceOption = WhitespaceOption.DEFAULT;
    647 635  
    skipped 114 lines
  • ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/web/page/project/issues/boards/IssueBoardsPage.java
    skipped 610 lines
    611 611   SpriteImage.getVersionedHref(IconScope.class, "plus")));
    612 612   }
    613 613  
    614  - }.setEscapeModelStrings(false).add(AttributeAppender.append("class", "btn btn-outline-secondary btn-hover-primary")));
     614 + }.setEscapeModelStrings(false).add(AttributeAppender.append("class", "btn btn-outline-secondary bg-white btn-hover-primary")));
    615 615   } else {
    616 616   form.add(new WebMarkupContainer("milestone").setVisible(false));
    617 617   }
    skipped 386 lines
  • ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/web/page/project/pullrequests/detail/activities/activity/PullRequestUpdatedPanel.java
    skipped 103 lines
    104 104   
    105 105   @Override
    106 106   protected PullRequest getPullRequest() {
    107  - return getUpdate().getRequest();
     107 + return null;
    108 108   }
    109 109  
    110 110   };
    skipped 43 lines
  • ■ ■ ■ ■ ■
    server-core/src/main/java/io/onedev/server/web/page/project/pullrequests/detail/mergepreview/MergePreviewPage.java
    skipped 95 lines
    96 96  
    97 97   commitState = new CommitDetailPage.State();
    98 98   commitState.revision = preview.getMergeCommitHash();
    99  - commitState.requestId = getPullRequest().getId();
    100 99   params = CommitDetailPage.paramsOf(projectModel.getObject(), commitState);
    101 100   fragment.add(new ViewStateAwarePageLink<Void>("mergedCommit", CommitDetailPage.class, params));
    102 101  
    skipped 178 lines
  • ■ ■ ■ ■
    server-plugin/pom.xml
    skipped 5 lines
    6 6   <parent>
    7 7   <groupId>io.onedev</groupId>
    8 8   <artifactId>server</artifactId>
    9  - <version>4.0.7</version>
     9 + <version>4.0.8</version>
    10 10   </parent>
    11 11   <dependencies>
    12 12   <dependency>
    skipped 18 lines
  • ■ ■ ■ ■
    server-plugin/server-plugin-archetype/pom.xml
    skipped 5 lines
    6 6   <parent>
    7 7   <groupId>io.onedev</groupId>
    8 8   <artifactId>server-plugin</artifactId>
    9  - <version>4.0.7</version>
     9 + <version>4.0.8</version>
    10 10   </parent>
    11 11   <build>
    12 12   <resources>
    skipped 44 lines
  • ■ ■ ■ ■
    server-plugin/server-plugin-authenticator-ldap/pom.xml
    skipped 4 lines
    5 5   <parent>
    6 6   <groupId>io.onedev</groupId>
    7 7   <artifactId>server-plugin</artifactId>
    8  - <version>4.0.7</version>
     8 + <version>4.0.8</version>
    9 9   </parent>
    10 10   <properties>
    11 11   <moduleClass>io.onedev.server.plugin.authenticator.ldap.LdapModule</moduleClass>
    skipped 3 lines
  • ■ ■ ■ ■
    server-plugin/server-plugin-buildspec-gradle/pom.xml
    skipped 4 lines
    5 5   <parent>
    6 6   <groupId>io.onedev</groupId>
    7 7   <artifactId>server-plugin</artifactId>
    8  - <version>4.0.7</version>
     8 + <version>4.0.8</version>
    9 9   </parent>
    10 10   <dependencies>
    11 11   <dependency>
    skipped 10 lines
  • ■ ■ ■ ■
    server-plugin/server-plugin-buildspec-maven/pom.xml
    skipped 4 lines
    5 5   <parent>
    6 6   <groupId>io.onedev</groupId>
    7 7   <artifactId>server-plugin</artifactId>
    8  - <version>4.0.7</version>
     8 + <version>4.0.8</version>
    9 9   </parent>
    10 10   <properties>
    11 11   <moduleClass>io.onedev.server.plugin.buildspec.maven.MavenModule</moduleClass>
    skipped 3 lines
  • ■ ■ ■ ■
    server-plugin/server-plugin-buildspec-node/pom.xml
    skipped 4 lines
    5 5   <parent>
    6 6   <groupId>io.onedev</groupId>
    7 7   <artifactId>server-plugin</artifactId>
    8  - <version>4.0.7</version>
     8 + <version>4.0.8</version>
    9 9   </parent>
    10 10   <properties>
    11 11   <moduleClass>io.onedev.server.plugin.buildspec.node.NodePluginModule</moduleClass>
    skipped 4 lines
  • ■ ■ ■ ■
    server-plugin/server-plugin-executor-docker/pom.xml
    skipped 4 lines
    5 5   <parent>
    6 6   <groupId>io.onedev</groupId>
    7 7   <artifactId>server-plugin</artifactId>
    8  - <version>4.0.7</version>
     8 + <version>4.0.8</version>
    9 9   </parent>
    10 10   <properties>
    11 11   <moduleClass>io.onedev.server.plugin.docker.DockerModule</moduleClass>
    skipped 3 lines
  • ■ ■ ■ ■
    server-plugin/server-plugin-executor-kubernetes/pom.xml
    skipped 5 lines
    6 6   <parent>
    7 7   <groupId>io.onedev</groupId>
    8 8   <artifactId>server-plugin</artifactId>
    9  - <version>4.0.7</version>
     9 + <version>4.0.8</version>
    10 10   </parent>
    11 11   <properties>
    12 12   <moduleClass>io.onedev.server.plugin.executor.kubernetes.KubernetesModule</moduleClass>
    skipped 3 lines
  • ■ ■ ■ ■
    server-plugin/server-plugin-report-html/pom.xml
    skipped 5 lines
    6 6   <parent>
    7 7   <groupId>io.onedev</groupId>
    8 8   <artifactId>server-plugin</artifactId>
    9  - <version>4.0.7</version>
     9 + <version>4.0.8</version>
    10 10   </parent>
    11 11   <properties>
    12 12   <moduleClass>io.onedev.server.plugin.report.html.HtmlReportModule</moduleClass>
    skipped 2 lines
  • ■ ■ ■ ■
    server-plugin/server-plugin-report-markdown/pom.xml
    skipped 4 lines
    5 5   <parent>
    6 6   <groupId>io.onedev</groupId>
    7 7   <artifactId>server-plugin</artifactId>
    8  - <version>4.0.7</version>
     8 + <version>4.0.8</version>
    9 9   </parent>
    10 10   <properties>
    11 11   <moduleClass>io.onedev.server.plugin.report.markdown.MarkdownReportModule</moduleClass>
    skipped 3 lines
  • ■ ■ ■ ■
    server-plugin/server-plugin-sso-openid/pom.xml
    skipped 5 lines
    6 6   <parent>
    7 7   <groupId>io.onedev</groupId>
    8 8   <artifactId>server-plugin</artifactId>
    9  - <version>4.0.7</version>
     9 + <version>4.0.8</version>
    10 10   </parent>
    11 11   <dependencies>
    12 12   <dependency>
    skipped 10 lines
  • ■ ■ ■ ■
    server-product/pom.xml
    skipped 6 lines
    7 7   <parent>
    8 8   <groupId>io.onedev</groupId>
    9 9   <artifactId>server</artifactId>
    10  - <version>4.0.7</version>
     10 + <version>4.0.8</version>
    11 11   </parent>
    12 12   <dependencies>
    13 13   <dependency>
    skipped 56 lines
Please wait...
Page is in error, reload to recover