Skip to content

Commit bb1da19

Browse files
authored
Push tags (#1279)
* Push tags * lint the code
1 parent 924be51 commit bb1da19

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

jupyterlab_git/git.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,11 +1235,14 @@ async def push(
12351235
auth=None,
12361236
set_upstream=False,
12371237
force=False,
1238+
tags=True,
12381239
):
12391240
"""
12401241
Execute `git push $UPSTREAM $BRANCH`. The choice of upstream and branch is up to the caller.
12411242
"""
12421243
command = ["git", "push"]
1244+
if tags:
1245+
command.append("--tags")
12431246
if force:
12441247
command.append("--force-with-lease")
12451248
if set_upstream:

jupyterlab_git/tests/test_pushpull.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ async def test_git_push_fail():
313313

314314
# Then
315315
mock_execute.assert_called_once_with(
316-
["git", "push", "test_origin", "HEAD:test_master"],
316+
["git", "push", "--tags", "test_origin", "HEAD:test_master"],
317317
cwd="test_curr_path",
318318
timeout=20,
319319
env={"TEST": "test", "GIT_TERMINAL_PROMPT": "0"},
@@ -345,7 +345,7 @@ async def test_git_push_with_auth_fail():
345345

346346
# Then
347347
mock_execute_with_authentication.assert_called_once_with(
348-
["git", "push", "test_origin", "HEAD:test_master"],
348+
["git", "push", "--tags", "test_origin", "HEAD:test_master"],
349349
cwd="test_curr_path",
350350
timeout=20,
351351
env={"TEST": "test", "GIT_TERMINAL_PROMPT": "1"},
@@ -374,7 +374,7 @@ async def test_git_push_success():
374374

375375
# Then
376376
mock_execute.assert_called_once_with(
377-
["git", "push", ".", "HEAD:test_master"],
377+
["git", "push", "--tags", ".", "HEAD:test_master"],
378378
cwd="test_curr_path",
379379
timeout=20,
380380
env={"TEST": "test", "GIT_TERMINAL_PROMPT": "0"},
@@ -403,7 +403,7 @@ async def test_git_push_with_auth_success():
403403

404404
# Then
405405
mock_execute_with_authentication.assert_called_once_with(
406-
["git", "push", ".", "HEAD:test_master"],
406+
["git", "push", "--tags", ".", "HEAD:test_master"],
407407
cwd="test_curr_path",
408408
timeout=20,
409409
env={"TEST": "test", "GIT_TERMINAL_PROMPT": "1"},
@@ -466,7 +466,7 @@ async def test_git_push_with_auth_and_cache_credentials():
466466
is_binary=False,
467467
),
468468
call(
469-
["git", "push", ".", "HEAD:test_master"],
469+
["git", "push", "--tags", ".", "HEAD:test_master"],
470470
cwd=test_path,
471471
timeout=20,
472472
env={**os.environ, "GIT_TERMINAL_PROMPT": "1"},
@@ -511,7 +511,7 @@ async def test_git_push_with_auth_and_cache_credentials_and_existing_credential_
511511
is_binary=False,
512512
),
513513
call(
514-
["git", "push", ".", "HEAD:test_master"],
514+
["git", "push", "--tags", ".", "HEAD:test_master"],
515515
cwd=test_path,
516516
timeout=20,
517517
env={**os.environ, "GIT_TERMINAL_PROMPT": "1"},
@@ -522,3 +522,29 @@ async def test_git_push_with_auth_and_cache_credentials_and_existing_credential_
522522
]
523523
)
524524
assert {"code": 0, "message": ""} == actual_response
525+
526+
527+
@pytest.mark.asyncio
528+
async def test_git_push_no_tags_success():
529+
with patch("os.environ", {"TEST": "test"}):
530+
with patch("jupyterlab_git.git.execute") as mock_execute:
531+
# Given
532+
output = "output"
533+
mock_execute.return_value = maybe_future((0, output, "does not matter"))
534+
535+
# When
536+
actual_response = await Git().push(
537+
".", "HEAD:test_master", "test_curr_path", tags=False
538+
)
539+
540+
# Then
541+
mock_execute.assert_called_once_with(
542+
["git", "push", ".", "HEAD:test_master"],
543+
cwd="test_curr_path",
544+
timeout=20,
545+
env={"TEST": "test", "GIT_TERMINAL_PROMPT": "0"},
546+
username=None,
547+
password=None,
548+
is_binary=False,
549+
)
550+
assert {"code": 0, "message": output} == actual_response

0 commit comments

Comments
 (0)