public long lastModified()

in src/main/java/org/apache/jenkins/gitpubsub/ASFGitSCMFileSystem.java [127:171]


    public long lastModified() throws IOException, InterruptedException {
        if (refOrHash.startsWith(Constants.R_TAGS)) {
            String tagUrl = buildTemplateWithRemote("{+server}{?p}{;a,h}", remote)
                    .set("a", "tag")
                    .set("h", refOrHash)
                    .expand();
            Document doc;
            try {
                doc = fetchDocument(tagUrl);
            } catch (HttpStatusException e) {
                if (e.getStatusCode() == 404) {
                    // must be a lightweight tag
                    doc = null;
                } else {
                    throw e;
                }
            }
            if (doc != null) {
                Elements elements = doc.select("table.object_header tr td span.datetime");
                try {
                    return new SimpleDateFormat(RFC_2822).parse(elements.get(0).text())
                            .getTime();
                } catch (ParseException e) {
                    throw new IOException(
                            "Unexpected date format, expected RFC 2822, got " + elements.get(1).text());
                } catch (IndexOutOfBoundsException e) {
                    throw new IOException(
                            "Unexpected response body, expecting two timestamps only got " + elements.size());
                }
            }
        }
        String commitUrl = buildTemplateWithRemote("{+server}{?p}{;a,h}", remote)
                .set("a", "commit")
                .set("h", refOrHash)
                .expand();
        Document doc = fetchDocument(commitUrl);
        Elements elements = doc.select("table.object_header tr td span.datetime");
        try {
            return new SimpleDateFormat(RFC_2822).parse(elements.get(1).text()).getTime();
        } catch (ParseException e) {
            throw new IOException("Unexpected date format, expected RFC 2822, got " + elements.get(1).text());
        } catch (IndexOutOfBoundsException e) {
            throw new IOException("Unexpected response body, expecting two timestamps only got " + elements.size());
        }
    }