本文整理汇总了Java中com.atlassian.bitbucket.repository.RefChange类的典型用法代码示例。如果您正苦于以下问题:Java RefChange类的具体用法?Java RefChange怎么用?Java RefChange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RefChange类属于com.atlassian.bitbucket.repository包,在下文中一共展示了RefChange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPushEvent
import com.atlassian.bitbucket.repository.RefChange; //导入依赖的package包/类
public static BitbucketPushEvent createPushEvent(RepositoryRefsChangedEvent event,
ApplicationPropertiesService appPropSvc)
{
BitbucketPushEvent pushEvent = new BitbucketPushEvent();
pushEvent.setActor(Models.createActor(event.getUser()));
pushEvent.setRepository(Models.createRepository(event.getRepository(), appPropSvc));
List<BitbucketPushChange> changes = new ArrayList<>();
for (RefChange change : event.getRefChanges())
{
changes.add(Models.createChange(change));
}
BitbucketPushDetail push = new BitbucketPushDetail();
push.setChanges(changes);
pushEvent.setPush(push);
return pushEvent;
}
示例2: compactCommitLog
import com.atlassian.bitbucket.repository.RefChange; //导入依赖的package包/类
private void compactCommitLog(RepositoryPushEvent event, RefChange refChange, SlackPayload payload, NavBuilder.Repo urlBuilder, List<Commit> myCommits) {
if (myCommits.size() == 0) {
// If there are no commits, no reason to add anything
}
SlackAttachment commits = new SlackAttachment();
commits.setColor(ColorCode.GRAY.getCode());
// Since the branch is now in the main commit line, title is not needed
//commits.setTitle(String.format("[%s:%s]", event.getRepository().getName(), refChange.getRefId().replace("refs/heads", "")));
StringBuilder attachmentFallback = new StringBuilder();
StringBuilder commitListBlock = new StringBuilder();
for (Commit c : myCommits) {
String commitUrl = urlBuilder.commit(c.getId()).buildAbsolute();
String firstCommitMessageLine = c.getMessage().split("\n")[0];
// Note that we changed this to put everything in one attachment because otherwise it
// doesn't get collapsed in slack (the see more... doesn't appear)
commitListBlock.append(String.format("<%s|`%s`>: %s - _%s_\n",
commitUrl, c.getDisplayId(), firstCommitMessageLine, c.getAuthor().getName()));
attachmentFallback.append(String.format("%s: %s\n", c.getDisplayId(), firstCommitMessageLine));
}
commits.setText(commitListBlock.toString());
commits.setFallback(attachmentFallback.toString());
payload.addAttachment(commits);
}
示例3: verboseCommitLog
import com.atlassian.bitbucket.repository.RefChange; //导入依赖的package包/类
private void verboseCommitLog(RepositoryPushEvent event, RefChange refChange, SlackPayload payload, NavBuilder.Repo urlBuilder, String text, List<Commit> myCommits) {
for (Commit c : myCommits) {
SlackAttachment attachment = new SlackAttachment();
attachment.setFallback(text);
attachment.setColor(ColorCode.GRAY.getCode());
SlackAttachmentField field = new SlackAttachmentField();
attachment.setTitle(String.format("[%s:%s] - %s", event.getRepository().getName(), refChange.getRef().getId().replace("refs/heads", ""), c.getId()));
attachment.setTitle_link(urlBuilder.commit(c.getId()).buildAbsolute());
field.setTitle("comment");
field.setValue(c.getMessage());
field.setShort(false);
attachment.addField(field);
payload.addAttachment(attachment);
}
}
示例4: onReceive
import com.atlassian.bitbucket.repository.RefChange; //导入依赖的package包/类
@Override
public boolean onReceive(Repository repository, Collection<RefChange> collection, HookResponse hookResponse) {
Config config = configDao.getConfigForRepo(repository.getProject().getKey(), repository.getSlug());
UserProfile user = userManager.getRemoteUser();
for(RefChange ch : collection) {
String branch = regexUtils.formatBranchName(ch.getRef().getId());
Set<String> excluded = newHashSet(concat(config.getExcludedUsers(), userUtils.dereferenceGroups(config.getExcludedGroups())));
if(regexUtils.match(config.getBlockedCommits(), branch) && !excluded.contains(user.getUsername())) {
hookResponse.err().write("\n" +
"******************************\n" +
"* !! Commit Rejected !! *\n" +
"******************************\n\n" +
"Direct commits are not allowed\n" +
"to branch [" + branch + "].\n\n"
);
return false;
}
}
return true;
}
示例5: postReceive
import com.atlassian.bitbucket.repository.RefChange; //导入依赖的package包/类
@Override
public void postReceive(RepositoryHookContext repositoryHookContext, Collection<RefChange> refChanges) {
if (refChanges.size() != 1) {
return;
}
RefChange refChange = refChanges.iterator().next();
try {
postReceive(repositoryHookContext, refChange);
} catch (NoSuchCommitException ignored) {
// branch was deleted
} catch (RuntimeException e) {
logger.error("Failed to generate jira JIRA version and link issues", e);
}
}
示例6: createJiraVersionGenerator
import com.atlassian.bitbucket.repository.RefChange; //导入依赖的package包/类
private JiraVersionGenerator createJiraVersionGenerator(RepositoryHookContext repositoryHookContext,
RefChange refChange) {
Iterator<Commit> commitIterator = CommitPageCrawler.of(commitService, repositoryHookContext.getRepository(), refChange);
Commit releaseCommit = commitIterator.next();
String repositoryName = repositoryHookContext.getRepository().getName();
CommitMessageVersionExtractor commitMessageVersionExtractor = getNonEmptySetting(repositoryHookContext, VersionPatternValidator.SETTINGS_KEY)
.map(versionPattern -> new CommitMessageVersionExtractor(repositoryName, versionPattern))
.orElseGet(() -> new CommitMessageVersionExtractor(repositoryName));
return new JiraVersionGenerator(jiraService,
releaseCommit,
commitIterator,
commitMessageVersionExtractor,
ClockFactory.getInstance());
}
示例7: getChanges
import com.atlassian.bitbucket.repository.RefChange; //导入依赖的package包/类
@Override
public Iterable<Change> getChanges(Iterable<RefChange> refChanges, final Repository repository) {
List<Change> changes = new ArrayList<>();
for (RefChange refChange : refChanges) {
Iterable<String> commitIds = StreamSupport.stream(getCommitsBetween(repository, refChange).spliterator(),false).map(Functions.COMMIT_TO_COMMIT_ID).collect(Collectors.toList());
if (Iterables.size(commitIds) == 0) {
return Collections.emptySet();
}
Iterable<Changeset> changesets = getChangesets(repository, commitIds);
for (Changeset changeset : changesets) {
Iterable<Change> values = changeset.getChanges().getValues();
for (Change change : values) {
changes.add(change);
}
}
}
return changes;
}
示例8: createChange
import com.atlassian.bitbucket.repository.RefChange; //导入依赖的package包/类
public static BitbucketPushChange createChange(RefChange change)
{
BitbucketPushChange result = new BitbucketPushChange();
BitbucketPushChange.State _new = null;
BitbucketPushChange.State _old = null;
switch (change.getType())
{
case ADD:
_new = new BitbucketPushChange.State();
_new.setType(change.getRef().getType());
_new.setName(change.getRef().getDisplayId());
_new.setTarget(new BitbucketPushChange.State.Target(change.getToHash()));
result.setCreated(true);
result.setClosed(false);
break;
case DELETE:
_old = new BitbucketPushChange.State();
_old.setType(change.getRef().getType());
_old.setName(change.getRef().getDisplayId());
_old.setTarget(new BitbucketPushChange.State.Target(change.getFromHash()));
result.setCreated(false);
result.setClosed(true);
break;
case UPDATE:
_new = new BitbucketPushChange.State();
_new.setType(change.getRef().getType());
_new.setName(change.getRef().getDisplayId());
_new.setTarget(new BitbucketPushChange.State.Target(change.getToHash()));
_old = new BitbucketPushChange.State();
_old.setType(change.getRef().getType());
_old.setName(change.getRef().getDisplayId());
_old.setTarget(new BitbucketPushChange.State.Target(change.getFromHash()));
result.setCreated(false);
result.setClosed(false);
break;
}
result.setNew(_new);
result.setOld(_old);
return result;
}
示例9: onReceive
import com.atlassian.bitbucket.repository.RefChange; //导入依赖的package包/类
@Override
public boolean onReceive(@Nonnull RepositoryHookContext context, @Nonnull Collection<RefChange> refChanges, @Nonnull HookResponse hookResponse) {
Repository repository = context.getRepository();
FileNameHookSetting setting = getSettings(context.getSettings());
Optional<Pattern> branchesPattern = setting.getBranchesPattern();
Collection<RefChange> filteredRefChanges = refChanges.stream().filter(isNotDeleteRefChange).filter(isNotTagRefChange).collect(Collectors.toList());
if(branchesPattern.isPresent()) {
filteredRefChanges = filteredRefChanges.stream().filter(matchesBranchPattern(branchesPattern.get())).collect(Collectors.toList());
}
Iterable<Change> changes = changesetService.getChanges(filteredRefChanges, repository);
Collection<String> filteredPaths = StreamSupport.stream(changes.spliterator(), false).filter(isNotDeleteChange).map(Functions.CHANGE_TO_PATH).filter(setting.getIncludePattern().asPredicate()).collect(Collectors.toList());
if(setting.getExcludePattern().isPresent()) {
Pattern excludePattern = setting.getExcludePattern().get();
filteredPaths = filteredPaths.stream().filter(excludePattern.asPredicate().negate()).collect(Collectors.toList());
}
if (filteredPaths.size() > 0) {
hookResponse.out().println("=================================");
for (String path : filteredPaths) {
String msg;
if(branchesPattern.isPresent()) {
msg = String.format("File [%s] violates file name pattern [%s] for branch [%s].", path, setting.getIncludePattern().pattern(), branchesPattern.get());
} else {
msg = String.format("File [%s] violates file name pattern [%s].", path, setting.getIncludePattern().pattern());
}
hookResponse.out().println(msg);
}
hookResponse.out().println("=================================");
return false;
}
return true;
}
示例10: getCommitsBetween
import com.atlassian.bitbucket.repository.RefChange; //导入依赖的package包/类
private Iterable<Commit> getCommitsBetween(final Repository repository, final RefChange refChange) {
return new PagedIterable<>(pageRequest -> {
if (refChange.getFromHash().equals("0000000000000000000000000000000000000000")) {
return commitService.getCommitsBetween(new CommitsBetweenRequest.Builder(repository)
.include(refChange.getToHash())
.build(), pageRequest);
}
return commitService.getCommitsBetween(new CommitsBetweenRequest.Builder(repository)
.exclude(refChange.getFromHash())
.include(refChange.getToHash())
.build(), pageRequest);
}, PAGE_REQUEST);
}
示例11: onRefsChangedEvent
import com.atlassian.bitbucket.repository.RefChange; //导入依赖的package包/类
@EventListener
public void onRefsChangedEvent(RepositoryRefsChangedEvent event)
{
Repository repository = event.getRepository();
for(RefChange refChange : event.getRefChanges())
{
if(refChange.getType() == RefChangeType.DELETE) {continue;}
repositoryInformationService.PostChange(repository, refChange.getRefId(), refChange.getToHash(), null, null);
}
}
示例12: matchesBranchPattern
import com.atlassian.bitbucket.repository.RefChange; //导入依赖的package包/类
/**
* Predicate to check if the RefChange is matched by the @param branchesPattern
*/
static Predicate<RefChange> matchesBranchPattern (final Pattern branchesPattern) {
return refChange -> branchesPattern.matcher(refChange.getRef().getDisplayId()).matches();
}
示例13: getChanges
import com.atlassian.bitbucket.repository.RefChange; //导入依赖的package包/类
private Iterable<Pair<Change, Long>> getChanges(Repository repository, Iterable<RefChange> refChanges) {
List<Change> changes = StreamSupport.stream(changesetService.getChanges(refChanges, repository).spliterator(), false).filter(isNotDeleteChange).collect(Collectors.toList());
return zipWithSize(changes, repository);
}
示例14: postReceive
import com.atlassian.bitbucket.repository.RefChange; //导入依赖的package包/类
@Override
public void postReceive(RepositoryHookContext context, Collection<RefChange> refChanges)
{
//Don't need to do this because the event triggers will handle the receive.
}
示例15: getChanges
import com.atlassian.bitbucket.repository.RefChange; //导入依赖的package包/类
Iterable<Change> getChanges(Iterable<RefChange> refChanges, final Repository repository);