当前位置: 首页>>代码示例>>Java>>正文


Java RepoCommit类代码示例

本文整理汇总了Java中com.jcabi.github.RepoCommit的典型用法代码示例。如果您正苦于以下问题:Java RepoCommit类的具体用法?Java RepoCommit怎么用?Java RepoCommit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RepoCommit类属于com.jcabi.github包,在下文中一共展示了RepoCommit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: iterate

import com.jcabi.github.RepoCommit; //导入依赖的package包/类
@Override
@NotNull(message = "Iterable of commits can't be NULL")
public Iterable<RepoCommit> iterate(
    @NotNull(message = "params can't be NULL")
    final Map<String, String> params
) {
    return new MkIterable<RepoCommit>(
        this.storage, String.format("%s/commit", this.xpath()),
        new MkIterable.Mapping<RepoCommit>() {
            @Override
            public RepoCommit map(final XML xml) {
                return MkRepoCommits.this.get(
                    xml.xpath("sha/text()").get(0)
                );
            }
        }
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:19,代码来源:MkRepoCommits.java

示例2: canGetJsonWithCommits

import com.jcabi.github.RepoCommit; //导入依赖的package包/类
/**
 * MkCommitsComparison can get a JSON with commits.
 * @throws Exception if some problem inside
 */
@Test
public void canGetJsonWithCommits() throws Exception {
    final CommitsComparison cmp = new MkCommitsComparison(
        new MkStorage.InFile(), "test-9",
        new Coordinates.Simple("test_user_A", "test_repo_B")
    );
    MatcherAssert.assertThat(
        new CommitsComparison.Smart(cmp).commits(),
        Matchers.<RepoCommit>iterableWithSize(0)
    );
    MatcherAssert.assertThat(
        cmp.json().getJsonArray("commits"),
        Matchers.notNullValue()
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:20,代码来源:MkCommitsComparisonTest.java

示例3: canRemoveFile

import com.jcabi.github.RepoCommit; //导入依赖的package包/类
/**
 * MkContents should be able to create new files.
 *
 * @throws Exception if some problem inside
 */
@Test
public void canRemoveFile() throws Exception {
    final Repo repo = new MkGithub().randomRepo();
    final String path = "removeme.txt";
    this.createFile(repo, path);
    final JsonObject json = MkContentsTest
        .content(path, "theDeleteMessage")
        .add("committer", MkContentsTest.committer())
        .build();
    final RepoCommit commit = repo.contents().remove(json);
    MatcherAssert.assertThat(commit, Matchers.notNullValue());
    MatcherAssert.assertThat(
        commit.json().getString("message"),
        Matchers.equalTo("theDeleteMessage")
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:22,代码来源:MkContentsTest.java

示例4: canRemoveFileFromBranch

import com.jcabi.github.RepoCommit; //导入依赖的package包/类
/**
 * MkContents should be able to remove files from from non-default branches.
 *
 * @throws Exception if some problem inside
 */
@Test
public void canRemoveFileFromBranch() throws Exception {
    final String branch = "branch-1";
    final Repo repo = new MkGithub().randomRepo();
    final String path = "removeme.txt";
    this.createFile(repo, path);
    final JsonObject json = MkContentsTest
        .content(path, "theDeleteMessage")
        .add("ref", branch)
        .add("committer", MkContentsTest.committer())
        .build();
    final RepoCommit commit = repo.contents().remove(json);
    MatcherAssert.assertThat(commit, Matchers.notNullValue());
    MatcherAssert.assertThat(
        commit.json().getString("message"),
        Matchers.equalTo("theDeleteMessage")
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:24,代码来源:MkContentsTest.java

示例5: iterate

import com.jcabi.github.RepoCommit; //导入依赖的package包/类
@Override
public Iterable<RepoCommit> iterate(
    final Map<String, String> params
) {
    return new MkIterable<RepoCommit>(
        this.storage, String.format("%s/commit", this.xpath()),
        new MkIterable.Mapping<RepoCommit>() {
            @Override
            public RepoCommit map(final XML xml) {
                return MkRepoCommits.this.get(
                    xml.xpath("sha/text()").get(0)
                );
            }
        }
    );
}
 
开发者ID:jcabi,项目名称:jcabi-github,代码行数:17,代码来源:MkRepoCommits.java

示例6: remove

import com.jcabi.github.RepoCommit; //导入依赖的package包/类
@Override
public RepoCommit remove(
    final JsonObject content
) throws IOException {
    this.storage.lock();
    final String path = content.getString("path");
    // @checkstyle MultipleStringLiterals (20 lines)
    final String branch;
    try {
        if (content.containsKey("ref")) {
            branch = content.getString("ref");
        } else {
            branch = "master";
        }
        this.storage.apply(
            new Directives()
                .xpath(this.xpath())
                .xpath(String.format("content[path='%s']", path))
                .attr("ref", branch)
                .remove()
        );
        return this.commit(content);
    } finally {
        this.storage.unlock();
    }
}
 
开发者ID:jcabi,项目名称:jcabi-github,代码行数:27,代码来源:MkContents.java

示例7: update

import com.jcabi.github.RepoCommit; //导入依赖的package包/类
/**
 * Updates a file.
 * @param path The content path.
 * @param json JSON object containing updates to the content.
 * @return Commit related to this update.
 * @throws IOException If any I/O problem occurs.
 */
@Override
public RepoCommit update(
    final String path,
    final JsonObject json
) throws IOException {
    this.storage.lock();
    try {
        final String ref = "ref";
        final String branch;
        if (json.containsKey(ref)) {
            branch = json.getString(ref);
        } else {
            branch = "master";
        }
        final String xpath = String.format(
            // @checkstyle LineLengthCheck (1 line)
            "/github/repos/repo[@coords='%s']/contents/content[path='%s' and @ref='%s']",
            this.coords, path, branch
        );
        new JsonPatch(this.storage).patch(xpath, json);
        return this.commit(json);
    } finally {
        this.storage.unlock();
    }
}
 
开发者ID:jcabi,项目名称:jcabi-github,代码行数:33,代码来源:MkContents.java

示例8: compareTo

import com.jcabi.github.RepoCommit; //导入依赖的package包/类
@Override
public int compareTo(
    @NotNull(message = "other can't be NULL") final RepoCommit other
) {
    return new CompareToBuilder().append(
        this.repo().coordinates(),
        other.repo().coordinates()
    ).append(this.sha(), other.sha()).build();
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:10,代码来源:MkRepoCommit.java

示例9: get

import com.jcabi.github.RepoCommit; //导入依赖的package包/类
@Override
@NotNull(message = "repocommit can't be NULL")
public RepoCommit get(
    @NotNull(message = "sha shouldn't be NULL") final String sha
) {
    return new MkRepoCommit(
        this.storage, new MkRepo(this.storage, this.self, this.coords), sha
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:10,代码来源:MkRepoCommits.java

示例10: remove

import com.jcabi.github.RepoCommit; //导入依赖的package包/类
@Override
@NotNull(message = "commit is never NULL")
public RepoCommit remove(
    @NotNull(message = "content should not be NULL")
    final JsonObject content
) throws IOException {
    this.storage.lock();
    final String path = content.getString("path");
    // @checkstyle MultipleStringLiterals (20 lines)
    final String branch;
    try {
        if (content.containsKey("ref")) {
            branch = content.getString("ref");
        } else {
            branch = "master";
        }
        this.storage.apply(
            new Directives()
                .xpath(this.xpath())
                .xpath(String.format("content[path='%s']", path))
                .attr("ref", branch)
                .remove()
        );
        return this.commit(content);
    } finally {
        this.storage.unlock();
    }
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:29,代码来源:MkContents.java

示例11: update

import com.jcabi.github.RepoCommit; //导入依赖的package包/类
/**
 * Updates a file.
 * @param path The content path.
 * @param json JSON object containing updates to the content.
 * @return Commit related to this update.
 * @throws IOException If any I/O problem occurs.
 */
@Override
@NotNull(message = "updated commit is never NULL")
public RepoCommit update(
    @NotNull(message = "path cannot be NULL") final String path,
    @NotNull(message = "json should not be NULL") final JsonObject json
) throws IOException {
    this.storage.lock();
    try {
        final String ref = "ref";
        final String branch;
        if (json.containsKey(ref)) {
            branch = json.getString(ref);
        } else {
            branch = "master";
        }
        final String xpath = String.format(
            // @checkstyle LineLengthCheck (1 line)
            "/github/repos/repo[@coords='%s']/contents/content[path='%s' and @ref='%s']",
            this.coords, path, branch
        );
        new JsonPatch(this.storage).patch(xpath, json);
        return this.commit(json);
    } finally {
        this.storage.unlock();
    }
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:34,代码来源:MkContents.java

示例12: updatesFileCreateCommit

import com.jcabi.github.RepoCommit; //导入依赖的package包/类
/**
 * MkContents is able to update the file content.
 * During update new commit is created
 * @throws Exception Exception if some problem inside
 */
@Test
public void updatesFileCreateCommit() throws Exception {
    final MkStorage storage = new MkStorage.InFile();
    final Contents contents = MkContentsTest.repo(storage).contents();
    final String path = "file.txt";
    final JsonObject json = MkContentsTest
        .content(path, "theCreateMessage", "newContent")
        .add("committer", MkContentsTest.committer())
        .build();
    contents.create(json);
    final String xpath = "/github/repos/repo/commits/commit";
    MatcherAssert.assertThat(
        storage.xml().nodes(xpath),
        Matchers.<XML>iterableWithSize(1)
    );
    final JsonObject update = MkContentsTest
        .content(path, "theMessage", "blah")
        .build();
    MatcherAssert.assertThat(
        new RepoCommit.Smart(contents.update(path, update)).sha(),
        Matchers.not(Matchers.isEmptyOrNullString())
    );
    MatcherAssert.assertThat(
        new Content.Smart(contents.get(path, "master")).path(),
        Matchers.is(path)
    );
    MatcherAssert.assertThat(
        storage.xml().nodes(xpath),
        Matchers.<XML>iterableWithSize(2)
    );
}
 
开发者ID:cvrebert,项目名称:typed-github,代码行数:37,代码来源:MkContentsTest.java

示例13: compareTo

import com.jcabi.github.RepoCommit; //导入依赖的package包/类
@Override
public int compareTo(
    final RepoCommit other
) {
    return new CompareToBuilder().append(
        this.repo().coordinates(),
        other.repo().coordinates()
    ).append(this.sha(), other.sha()).build();
}
 
开发者ID:jcabi,项目名称:jcabi-github,代码行数:10,代码来源:MkRepoCommit.java

示例14: get

import com.jcabi.github.RepoCommit; //导入依赖的package包/类
@Override
public RepoCommit get(
    final String sha
) {
    return new MkRepoCommit(
        this.storage, new MkRepo(this.storage, this.self, this.coords), sha
    );
}
 
开发者ID:jcabi,项目名称:jcabi-github,代码行数:9,代码来源:MkRepoCommits.java

示例15: push

import com.jcabi.github.RepoCommit; //导入依赖的package包/类
/**
 * Post an event.
 * @param github Github client
 * @param events Events
 * @throws IOException If fails
 */
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
public void push(final Github github, final Events events)
    throws IOException {
    final String type = this.json.getString("type");
    final Body body;
    if ("Issue".equals(type) || "PullRequest".equals(type)) {
        body = new BoIssue(
            this.base,
            new Issue.Smart(
                github.repos().get(this.coords).issues().get(
                    Integer.parseInt(
                        StringUtils.substringAfterLast(
                            this.json.getString("url"),
                            "/"
                        )
                    )
                )
            )
        );
    } else if ("Commit".equals(type)) {
        body = new BoCommit(
            this.base,
            new RepoCommit.Smart(
                github.repos().get(this.coords).commits().get(
                    StringUtils.substringAfterLast(
                        this.json.getString("url"),
                        "/"
                    )
                )
            )
        );
    } else {
        try (final ByteArrayOutputStream baos =
            new ByteArrayOutputStream()) {
            Json.createWriter(baos).write(this.json);
            throw new IOException(
                String.format(
                    "subject ignored: %s", baos.toString()
                )
            );
        }
    }
    body.push(events);
}
 
开发者ID:yegor256,项目名称:wring,代码行数:51,代码来源:Subject.java


注:本文中的com.jcabi.github.RepoCommit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。