Compare commits
2 Commits
227d6ccd30
...
1f7354666b
| Author | SHA1 | Date | |
|---|---|---|---|
| 1f7354666b | |||
| 55b2c17913 |
18
how_to/Change_03.md
Normal file
18
how_to/Change_03.md
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
- init: Create new .ugit directory
|
||||||
|
|
||||||
|
The 'ugit init' command creates a new empty repository.
|
||||||
|
|
||||||
|
Git stores all repository data locally, in a subdirectory called ".git", so upon
|
||||||
|
initialization we'll create one.
|
||||||
|
|
||||||
|
I named the directory ".ugit" rather than ".git" so that it doesn't clash with
|
||||||
|
Git, but the idea is the same.
|
||||||
|
|
||||||
|
To implement 'init', we could have just called os.makedirs from cli.py, but I
|
||||||
|
want to have some separation between different logical parts of the code:
|
||||||
|
|
||||||
|
+ cli.py - In charge of parsing and processing user input.
|
||||||
|
+ data.py - Manages the data in .ugit directory. Here will be the code that
|
||||||
|
actually touches files on disk.
|
||||||
|
|
||||||
|
This separation will be useful as the code will get larger.
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from . import data
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -19,4 +22,5 @@ def parse_args():
|
|||||||
|
|
||||||
|
|
||||||
def init(args):
|
def init(args):
|
||||||
print("Hello, World!")
|
data.init()
|
||||||
|
print(f"Initialized empty ugit repository in {Path.cwd()}/{data.GIT_DIR}")
|
||||||
|
|||||||
7
ugit/data.py
Normal file
7
ugit/data.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
GIT_DIR = ".ugit"
|
||||||
|
|
||||||
|
|
||||||
|
def init():
|
||||||
|
Path.mkdir(GIT_DIR)
|
||||||
Reference in New Issue
Block a user