{
 "metadata": {
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.4-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python38364bit3ec8239d0440456baaf370e87148ec69",
   "display_name": "Python 3.8.3 64-bit"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2,
 "cells": [
  {
   "source": [
    "# Listing releases"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from ogr import GitlabService\n",
    "\n",
    "TOKEN = \"<paste-your-token-here>\"\n",
    "\n",
    "service = GitlabService(token=TOKEN, instance_url=\"https://gitlab.com\")\n",
    "project = service.get_project(repo=\"isleward\", namespace=\"Isleward\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "all_releases = project.get_releases()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime\n",
    "\n",
    "since = datetime.datetime(year=2020, month=1, day=1)\n",
    "releases_in_20 = filter(lambda release: datetime.datetime.fromisoformat(release.created_at.split('.')[0]) >= since, all_releases)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "v0.7.0: aa672412a1942af47801ded9f466fa1bf6139c04\n(https://gitlab.com/Isleward/isleward/-/archive/v0.7.0/isleward-v0.7.0.tar.gz)\nv0.6.1.2: 17584a7a97d21a5b01ece52139922b2dbea771da\n(https://gitlab.com/Isleward/isleward/-/archive/v0.6.1.2/isleward-v0.6.1.2.tar.gz)\nv0.6.1.1: 4c3229825dd8dc7414a52e6028bb084e47db4022\n(https://gitlab.com/Isleward/isleward/-/archive/v0.6.1.1/isleward-v0.6.1.1.tar.gz)\nv0.6.1: a77c207652946f2282efd73867dd35a595139991\n(https://gitlab.com/Isleward/isleward/-/archive/v0.6.1/isleward-v0.6.1.tar.gz)\nv0.6.0.3: e921bccd0d8efd2dcb69ff1ca5501c8fab9b47bf\n(https://gitlab.com/Isleward/isleward/-/archive/v0.6.0.3/isleward-v0.6.0.3.tar.gz)\nv0.6.0.2: 91d0c51f23dbd7d10ca40cf89220335366462428\n(https://gitlab.com/Isleward/isleward/-/archive/v0.6.0.2/isleward-v0.6.0.2.tar.gz)\nv0.6.0.1: 426081daec84f7c99549f605cec6647c7273d5bd\n(https://gitlab.com/Isleward/isleward/-/archive/v0.6.0.1/isleward-v0.6.0.1.tar.gz)\nv0.6: 2b36286a41dc97a7fd80d0b3e5720c6ffb44ebf7\n(https://gitlab.com/Isleward/isleward/-/archive/v0.6/isleward-v0.6.tar.gz)\nv0.5.1.1: 0fd19a0704bf19addfa53e09ad9c8087d004af0a\n(https://gitlab.com/Isleward/isleward/-/archive/v0.5.1.1/isleward-v0.5.1.1.tar.gz)\nv0.5.1: 5ce3bb47e5945499b5152f9287b0e4934a8d9037\n(https://gitlab.com/Isleward/isleward/-/archive/v0.5.1/isleward-v0.5.1.tar.gz)\nv0.5: 7f1d3fb33a57144ce8427e448a8661ce844098b5\n(https://gitlab.com/Isleward/isleward/-/archive/v0.5/isleward-v0.5.tar.gz)\nv0.4.4.5: fc06a73c18e6c5b5b5796ecc41d85de40b71128c\n(https://gitlab.com/Isleward/isleward/-/archive/v0.4.4.5/isleward-v0.4.4.5.tar.gz)\nv0.4.4.4: 75ba773adb0328c8e3bcd52d55fe9090c84aa0b6\n(https://gitlab.com/Isleward/isleward/-/archive/v0.4.4.4/isleward-v0.4.4.4.tar.gz)\nv0.4.4.3: f5e937eb0828156a170bd0c4e6d2d5786d759abd\n(https://gitlab.com/Isleward/isleward/-/archive/v0.4.4.3/isleward-v0.4.4.3.tar.gz)\nv0.4.4.2: 4f9379a2d831b0d418c1c7843160f7f7e01e59d6\n(https://gitlab.com/Isleward/isleward/-/archive/v0.4.4.2/isleward-v0.4.4.2.tar.gz)\nv0.4.4.1: 2279d5d59e96d9285be90d4050e3e4f385533bfc\n(https://gitlab.com/Isleward/isleward/-/archive/v0.4.4.1/isleward-v0.4.4.1.tar.gz)\nv0.4.4: 99b5629b21df552fd50899eda5d13640a007d8f8\n(https://gitlab.com/Isleward/isleward/-/archive/v0.4.4/isleward-v0.4.4.tar.gz)\nv0.4.3.1: e971964eefcfd8f1e3d6cea5e8c16babbd016249\n(https://gitlab.com/Isleward/isleward/-/archive/v0.4.3.1/isleward-v0.4.3.1.tar.gz)\nv0.4.3: 88f2e24755addeadfa164890623729965b05287b\n(https://gitlab.com/Isleward/isleward/-/archive/v0.4.3/isleward-v0.4.3.tar.gz)\nv0.4.2.4: 7cc57bde958824af45d30d5bd6dd51e4de7fc099\n(https://gitlab.com/Isleward/isleward/-/archive/v0.4.2.4/isleward-v0.4.2.4.tar.gz)\nv0.4.2.3: 81b8761bb8f5b3e3179ae1fd529746f18b70577c\n(https://gitlab.com/Isleward/isleward/-/archive/v0.4.2.3/isleward-v0.4.2.3.tar.gz)\nv0.4.2.2: 2980baa1eedb744673ff7c2efea015b81f6c0310\n(https://gitlab.com/Isleward/isleward/-/archive/v0.4.2.2/isleward-v0.4.2.2.tar.gz)\nv0.4.2.1: 66c156e29ac2c10a7c7159e6c537083b21d8a32f\n(https://gitlab.com/Isleward/isleward/-/archive/v0.4.2.1/isleward-v0.4.2.1.tar.gz)\nv0.4.2: 96e988416c76da5b37709ac0ce282c7b0d29c7fc\n(https://gitlab.com/Isleward/isleward/-/archive/v0.4.2/isleward-v0.4.2.tar.gz)\n"
    }
   ],
   "source": [
    "for release in releases_in_20:\n",
    "    print(f\"{release.title}: {release.git_tag.commit_sha}\\n({release.tarball_url})\")"
   ]
  }
 ]
}
