Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from stephenc/jenkins-36121
[JENKINS-36121] Do not trip the rate limit
- Loading branch information
Showing
10 changed files
with
1,057 additions
and
538 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
307 changes: 266 additions & 41 deletions
307
src/main/java/org/jenkinsci/plugins/github_branch_source/Connector.java
Large diffs are not rendered by default.
Oops, something went wrong.
226 changes: 133 additions & 93 deletions
226
src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubBuildStatusNotification.java
Large diffs are not rendered by default.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubClosable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2017 CloudBees, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
*/ | ||
package org.jenkinsci.plugins.github_branch_source; | ||
|
||
import java.io.Closeable; | ||
|
||
/** | ||
* Package private interface to allow {@link GitHubSCMFile} and {@link GitHubSCMFileSystem} to be aware of the state | ||
* of their connection. | ||
*/ | ||
interface GitHubClosable extends Closeable { | ||
boolean isOpen(); | ||
} |
77 changes: 77 additions & 0 deletions
77
src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubConsoleNote.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright 2017 CloudBees, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
|
||
package org.jenkinsci.plugins.github_branch_source; | ||
|
||
import hudson.Extension; | ||
import hudson.MarkupText; | ||
import hudson.console.ConsoleAnnotationDescriptor; | ||
import hudson.console.ConsoleAnnotator; | ||
import hudson.console.ConsoleNote; | ||
import java.io.IOException; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import org.kohsuke.accmod.Restricted; | ||
import org.kohsuke.accmod.restrictions.NoExternalUse; | ||
|
||
/** | ||
* A timestamped console note from the GitHub branch source. | ||
*/ | ||
@Restricted(NoExternalUse.class) | ||
public class GitHubConsoleNote extends ConsoleNote { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(GitHubConsoleNote.class.getName()); | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
private final long timestamp; | ||
|
||
public GitHubConsoleNote(long timestamp) { | ||
this.timestamp = timestamp; | ||
} | ||
|
||
@Override | ||
public ConsoleAnnotator annotate(Object context, MarkupText text, int charPos) { | ||
text.addMarkup(0, text.length(), String.format("<span class='greyed'><small>%tT</small> ", timestamp), "</span>"); | ||
return null; | ||
} | ||
|
||
public static String create(long timestamp, String text) { | ||
try { | ||
return new GitHubConsoleNote(timestamp).encode() + text; | ||
} catch (IOException e) { | ||
// impossible, but don't make this a fatal problem | ||
LOGGER.log(Level.WARNING, "Failed to serialize " + GitHubConsoleNote.class, e); | ||
return text; | ||
} | ||
} | ||
|
||
@Extension | ||
public static final class DescriptorImpl extends ConsoleAnnotationDescriptor { | ||
public String getDisplayName() { | ||
return "GitHub API Usage"; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.