Skip to content

Commit 5f822dd

Browse files
committed
Command-line argument repo_dir is changed
The optional third command-line argument, repo_dir, is now a keyword argument and the name is changed to target-dir; this allows us to avoid having to pass an empty branch_name as the second argument if you want to pass in the repo_dir(now target-dir) as the third argument. In the previous configuration, we used positional arguments: gitpuller git_url branch_name repo_dir Now, we use a keyword argument for target-dir: gitpuller git_url [branch_name] --target-dir [TARGET_DIR]
1 parent 1e57904 commit 5f822dd

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

nbgitpuller/pull.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,14 @@ def main():
304304
parser = argparse.ArgumentParser(description='Synchronizes a github repository with a local repository.')
305305
parser.add_argument('git_url', help='Url of the repo to sync')
306306
parser.add_argument('branch_name', default=None, help='Branch of repo to sync', nargs='?')
307-
parser.add_argument('repo_dir', default='.', help='Path to clone repo under', nargs='?')
307+
parser.add_argument('--target-dir', default='.', help='Path to clone repo under', nargs='?')
308+
308309
args = parser.parse_args()
309310

310311
for line in GitPuller(
311312
args.git_url,
312-
args.repo_dir,
313-
branch=args.branch_name if args.branch_name else None
313+
args.target_dir,
314+
branch=args.branch_name
314315
).pull():
315316
print(line)
316317

tests/test_gitpuller.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ def test_initialize():
9999
def command_line_test_helper(remote_path, branch, pusher_path):
100100
work_dir = "/".join(os.path.dirname(os.path.abspath(__file__)).split("/")[:-1]) + "/nbgitpuller"
101101
try:
102-
cmd = ['python3', 'pull.py', remote_path, branch, pusher_path]
102+
cmd = ['python3', 'pull.py', remote_path]
103+
if branch is not None:
104+
cmd += [branch]
105+
if pusher_path is not None:
106+
cmd += ['--target-dir', pusher_path]
103107
sp.check_output(
104108
cmd,
105109
cwd=work_dir
@@ -119,8 +123,9 @@ def test_command_line_existing_branch():
119123
assert subprocess_result
120124

121125

122-
def test_command_line_default_branch():
123-
branch = ""
126+
def test_command_line_no_branch_passed():
127+
# so it should use the default branch
128+
branch = None
124129
with Remote() as remote, Pusher(remote) as pusher:
125130
pusher.push_file('README.md', '1')
126131
remotepath = "file://%s" % os.path.abspath(remote.path)

0 commit comments

Comments
 (0)