Skip to content

Commit 2934922

Browse files
joaoebitwiseman
authored andcommitted
Implemented GitHub.doArchive
doArchive() will mark a repository as archived. Issue hub4j#472
1 parent 9042ff4 commit 2934922

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/main/java/org/kohsuke/github/GHRepository.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,27 @@ public void delete() throws IOException {
631631
}
632632
}
633633

634+
/**
635+
* Will archive and this repository as read-only. When a repository is archived, any operation
636+
* that can change its state is forbidden. This applies symmetrically if trying to unarchive it.
637+
*
638+
* <p>When you try to do any operation that modifies a read-only repository, it returns the
639+
* response:
640+
*
641+
* <pre>
642+
* org.kohsuke.github.HttpException: {
643+
* "message":"Repository was archived so is read-only.",
644+
* "documentation_url":"https://developer.github.com/v3/repos/#edit"
645+
* }
646+
* </pre>
647+
*
648+
* @throws IOException In case of any networking error or error from the server.
649+
*/
650+
public void doArchive() throws IOException {
651+
edit("archived", "true");
652+
archived = true;
653+
}
654+
634655
/**
635656
* Sort orders for listing forks
636657
*/

0 commit comments

Comments
 (0)