update module2.ipynb

This commit is contained in:
Yavuz Sava 2025-03-06 13:02:34 +03:00
parent 02395f2d7e
commit 1bd53ad044

View File

@ -805,7 +805,340 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# "
"# Rollbacks\n",
"\n",
"This reading contains the code used in the instructional videos from [**Rollbacks**<svg aria-labelledby=\"cds-react-aria2659598955-:rt9:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria2659598955-:rt9:\"><title id=\"cds-react-aria2659598955-:rt9:-title\">Opens in a new tab</title></svg>](https://www.coursera.org/learn/introduction-git-github/lecture/21kjM/rollbacks)\n",
"\n",
"## Introduction\n",
"\n",
"This follow-along reading is organized to match the content in the video that follows. It contains the same code shown in the next video. These code blocks will provide you with the opportunity to see how the code is written and can be used as a reference as you work through the course. \n",
"\n",
"You can follow along in the reading as the instructor discusses the code or review the code after watching the video.\n",
"\n",
"```bash\n",
"cd scripts\n",
"\n",
"atom all\\_checks.py\n",
"```\n",
"\n",
"## File in video\n",
"\n",
"```bash\n",
"#!/usr/bin/env python3\n",
"\n",
"import os\n",
"\n",
"import sys\n",
"\n",
"def check\\_reboot():\n",
"\n",
"    \"\"\"Returns True if the computer has a pending reboot.\"\"\"\n",
"\n",
"    return os.path.exists(\"/run/reboot-required\")\n",
"\n",
"def main():\n",
"\n",
"    if check\\_reboot():\n",
"\n",
"        print(\"Pending Reboot.\")\n",
"\n",
"        sys.exit(1)\n",
"\n",
"    if disk\\_full():\n",
"\n",
"        print(\"Disk Full.\")\n",
"\n",
"        sys.exit(1)\n",
"\n",
"    print(\"Everything ok.\")\n",
"\n",
"    sys.exit(0)\n",
"\n",
"main()\n",
"```\n",
"\n",
"```bash\n",
"git commit \\-a \\-m 'Add call to disk\\_full function'\n",
"```\n",
"\n",
"**Code output:**\n",
"\n",
"\\[master ec61497\\] Add call to disk\\_full function\n",
"\n",
" 1 file changed, 4 insertions(+)\n",
"\n",
"```bash\n",
"./all\\_checks.py \n",
"```\n",
"\n",
"**Code output:**\n",
"\n",
"Traceback (most recent call last):\n",
"\n",
"  File \"./all\\_checks.py\", line 22, in <module>\n",
"\n",
"    main()\n",
"\n",
"  File \"./all\\_checks.py\", line 15, in main\n",
"\n",
"    if disk\\_full():\n",
"\n",
"NameError: name 'disk\\_full' is not defined\n",
"\n",
"```bash\n",
"git revert HEAD\n",
"```\n",
"\n",
"**Code output:**\n",
"\n",
"Revert \"Add call to disk\\_full function\"\n",
"\n",
"Reason for rollback: The disk\\_full function is undefined.\n",
"\n",
"This reverts commit ec614976e1665b40134d2c01921f9b0fbf89d1e2.\n",
"\n",
"\\# Please enter the commit message for your changes. Lines starting\n",
"\n",
"\\# with '#' will be ignored, and an empty message aborts the commit.\n",
"\n",
"\\# On branch master\n",
"\n",
"\\# Changes to be committed:\n",
"\n",
"\\#       modified:   all\\_checks.py\n",
"\n",
"\\# Untracked files:\n",
"\n",
"\\#       output.txt\n",
"\n",
"```bash\n",
"git revert HEAD\n",
"```\n",
"\n",
"**Code output:**\n",
"\n",
"\\[master 91c4968\\] Revert \"Add call to disk\\_full function\"\n",
"\n",
" 1 file changed, 4 deletions(-)\n",
"\n",
"```bash\n",
"git log \\-p \\-2\n",
"```\n",
"\n",
"**Code output:**\n",
"\n",
"commit 91c4968ebd80de900d71b9bc3f332f53149ac57d (HEAD -> master)\n",
"\n",
"Author: My name <me@example.com>\n",
"\n",
"Date:   Tue Jul 16 21:43:18 2019 +0200\n",
"\n",
"    Revert \"Add call to disk\\_full function\"\n",
"\n",
"    Reason for rollback: The disk\\_full function is undefined.\n",
"\n",
"    This reverts commit ec614976e1665b40134d2c01921f9b0fbf89d1e2.\n",
"\n",
"diff --git a/all\\_checks.py b/all\\_checks.py\n",
"\n",
"index 21da366..fdc4476 100755\n",
"\n",
"\\--- a/all\\_checks.py\n",
"\n",
"+++ b/all\\_checks.py\n",
"\n",
"@@ -12,10 +12,6 @@ def main():\n",
"\n",
"         print(\"Pending Reboot.\")\n",
"\n",
"         sys.exit(1)\n",
"\n",
"\\-    if disk\\_full():\n",
"\n",
"\\-        print(\"Disk Full.\")\n",
"\n",
"\\-        sys.exit(1)\n",
"\n",
"\\-\n",
"\n",
"     print(\"Everything ok.\")\n",
"\n",
"     sys.exit(0)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Identifying a Commit\n",
"\n",
"This reading contains the code used in the instructional videos from [**Identifying a commit**<svg aria-labelledby=\"cds-react-aria2659598955-:r16k:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria2659598955-:r16k:\"><title id=\"cds-react-aria2659598955-:r16k:-title\">Opens in a new tab</title></svg>](https://www.coursera.org/learn/introduction-git-github/lecture/WqddF/identifying-a-commit)**.** \n",
"\n",
"## Introduction\n",
"\n",
"This follow-along reading is organized to match the content in the video that follows. It contains the same code shown in the next video. These code blocks will provide you with the opportunity to see how the code is written and can be used as a reference as you work through the course. \n",
"\n",
"You can follow along in the reading as the instructor discusses the code or review the code after watching the video.\n",
"\n",
"```bash\n",
"cd checks\n",
"\n",
"git log \\-1\n",
"```\n",
"\n",
"**Code output:**\n",
"\n",
"commit abb063210c1f011b0d6470a4c5f1d8f672edd3ef (HEAD -> master)\n",
"\n",
"Author: My name <me@example.com>\n",
"\n",
"Date:   Mon Jul 15 22:20:45 2019 +0200\n",
"\n",
"    Add a gitignore file, ignoring .DS\\_STORE files\n",
"\n",
"```bash\n",
"git log \\-2\n",
"```\n",
"\n",
"**Code output:**\n",
"\n",
"commit abb063210c1f011b0d6470a4c5f1d8f672edd3ef (HEAD -> master)\n",
"\n",
"Author: My name <me@example.com>\n",
"\n",
"Date:   Mon Jul 15 22:20:45 2019 +0200\n",
"\n",
"    Add a gitignore file, ignoring .DS\\_STORE files\n",
"\n",
"commit 7d7167b2db44abf8cf014230f9b9708786e41c2a\n",
"\n",
"Author: My name <me@example.com>\n",
"\n",
"Date:   Mon Jul 15 21:52:59 2019 +0200\n",
"\n",
"    New name for disk\\_usage.py\n",
"\n",
"```bash\n",
"git show 30e70712882267ca2dd749acfa02ea3aacfd0b24\n",
"```\n",
"\n",
"**Code output:**\n",
"\n",
"Author: My name <me@example.com>\n",
"\n",
"Date:   Mon Jul 15 21:52:59 2019 +0200\n",
"\n",
"    New name for disk\\_usage.py\n",
"\n",
"diff --git a/disk\\_usage.py b/check\\_free\\_space.py\n",
"\n",
"similarity index 100%\n",
"\n",
"rename from disk\\_usage.py\n",
"\n",
"rename to check\\_free\\_space.py\n",
"\n",
"```bash\n",
"git show 30\n",
"```\n",
"\n",
"**Code output:**\n",
"\n",
"fatal: ambiguous argument '7d': unknown revision or path not in the working tree.\n",
"\n",
"Use '--' to separate paths from revisions, like this:\n",
"\n",
"'git <command> \\[<revision>...\\] -- \\[<file>...\\]'\n",
"\n",
"```bash\n",
"git show 30e7\n",
"```\n",
"\n",
"**Code output:**\n",
"\n",
"commit 7d7167b2db44abf8cf014230f9b9708786e41c2a\n",
"\n",
"Author: My name <me@example.com>\n",
"\n",
"Date:   Mon Jul 15 21:52:59 2019 +0200\n",
"\n",
"    New name for disk\\_usage.py\n",
"\n",
"diff --git a/disk\\_usage.py b/check\\_free\\_space.py\n",
"\n",
"similarity index 100%\n",
"\n",
"rename from disk\\_usage.py\n",
"\n",
"rename to check\\_free\\_space.py\n",
"\n",
"```bash\n",
"git revert 30e7\n",
"```\n",
"\n",
"**Code output:**\n",
"\n",
"Revert \"New name for disk\\_usage.py\"\n",
"\n",
"Rollback reason: the previous name was actually better.\n",
"\n",
"This reverts commit 7d7167b2db44abf8cf014230f9b9708786e41c2a.\n",
"\n",
"\\# Please enter the commit message for your changes. Lines starting\n",
"\n",
"\\# with '#' will be ignored, and an empty message aborts the commit.\n",
"\n",
"\\# On branch master\n",
"\n",
"\\# Changes to be committed:\n",
"\n",
"\\#       renamed:    check\\_free\\_space.py -> disk\\_usage.py\n",
"\n",
"```bash\n",
"git revert 7d71\n",
"```\n",
"\n",
"**Code output:**\n",
"\n",
"\\[master 80b2dac\\] Revert \"New name for disk\\_usage.py\"\n",
"\n",
" 1 file changed, 0 insertions(+), 0 deletions(-)\n",
"\n",
" rename check\\_free\\_space.py => disk\\_usage.py (100%)\n",
"\n",
"```bash\n",
"git show 7d1de19\n",
"```\n",
"\n",
"**Code output:**\n",
"\n",
"commit 80b2dacef4b567196e61651064f03089c5e70b5e (HEAD -> master)\n",
"\n",
"Author: My name <me@example.com>\n",
"\n",
"Date:   Wed Jul 17 00:02:39 2019 +0200\n",
"\n",
"    Revert \"New name for disk\\_usage.py\"\n",
"\n",
"    Rollback reason: the previous name was actually better.\n",
"\n",
"    This reverts commit 7d7167b2db44abf8cf014230f9b9708786e41c2a.\n",
"\n",
"diff --git a/check\\_free\\_space.py b/disk\\_usage.py\n",
"\n",
"similarity index 100%\n",
"\n",
"rename from check\\_free\\_space.py\n",
"\n",
"rename to disk\\_usage.py"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# \n",
"\n"
]
}
],