Post

16 Rollbacks

16 Rollbacks

Command:

1
2
$ cd scripts
$ vim all_checks.py

File with code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python3
  
import os
import sys

def check_reboot():
    """Returns True if the computer has a pending reboot."""
    return os.path.exists("/run/reboot-required")

def main():
    if check_reboot():
        print("Pending Reboot.")
        sys.exit(1)

    if disk_full():
        print("Disk Full.")
        sys.exit(1)

    print("Everything ok.")
    sys.exit(0)

main()

Command:

1
$ git commit -a -m 'Add call to disk_full function'

Code output:

1
2
3
[master ec61497] Add call to disk_full function

 1 file changed, 4 insertions(+)

Command:

1
$ ./all_checks.py 

Code output:

1
2
3
4
5
6
7
8
9
10
11
Traceback (most recent call last):

  File "./all_checks.py", line 22, in <module>

    main()

  File "./all_checks.py", line 15, in main

    if disk_full():

NameError: name 'disk_full' is not defined

Command:

1
$ git revert HEAD

Modify the commit message:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Revert "Add call to disk_full function"

Reason for rollback: The disk_full function is undefined.

This reverts commit ec614976e1665b40134d2c01921f9b0fbf89d1e2.

# Please enter the commit message for your changes. Lines starting

# with '#' will be ignored, and an empty message aborts the commit.

#

# On branch master

# Changes to be committed:

#       modified:   all_checks.py

#

# Untracked files:

#       output.txt

#

Code output:

1
2
3
[master 91c4968] Revert "Add call to disk_full function"

 1 file changed, 4 deletions(-)

Command:

1
$ git log -p -2

Code output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
commit 91c4968ebd80de900d71b9bc3f332f53149ac57d (HEAD -> master)

Author: artwalker <artwalker@example.com>

Date:   Tue Jul 16 21:43:18 2023 +0200

    Revert "Add call to disk_full function"

    

    Reason for rollback: The disk_full function is undefined.

    

    This reverts commit ec614976e1665b40134d2c01921f9b0fbf89d1e2.

diff --git a/all_checks.py b/all_checks.py

index 21da366..fdc4476 100755

--- a/all_checks.py

+++ b/all_checks.py

@@ -12,10 +12,6 @@ def main():

         print("Pending Reboot.")

         sys.exit(1)

 

-    if disk_full():

-        print("Disk Full.")

-        sys.exit(1)

-

     print("Everything ok.")

     sys.exit(0)
This post is licensed under CC BY 4.0 by the author.