mih / datalad-mihextras

DataLad extension with special interest functionality or drafts of future additions to DataLad proper
Other
1 stars 1 forks source link

BF(TST): Do specify the branch and set it upstream during push for older git #33

Closed yarikoptic closed 2 years ago

yarikoptic commented 2 years ago

Full or partially addresses https://github.com/mih/datalad-mihextras/issues/27 . Best to close whenever datalad-extensions turns green

codeclimate[bot] commented 2 years ago

Code Climate has analyzed commit 5f7eb3c5 and detected 0 issues on this pull request.

View more on Code Climate.

codecov[bot] commented 2 years ago

Codecov Report

Merging #33 (5f7eb3c) into master (3773adb) will decrease coverage by 7.52%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #33      +/-   ##
==========================================
- Coverage   57.01%   49.49%   -7.53%     
==========================================
  Files          15       13       -2     
  Lines        1161      982     -179     
==========================================
- Hits          662      486     -176     
+ Misses        499      496       -3     
Impacted Files Coverage Δ
...ad_mihextras/gitremote/tests/test_datalad_annex.py 97.45% <100.00%> (ø)
datalad_mihextras/__init__.py 100.00% <0.00%> (ø)
datalad_mihextras/tests/test_register.py 100.00% <0.00%> (ø)
datalad_mihextras/configuration.py
datalad_mihextras/tests/test_configuration.py

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 3773adb...5f7eb3c. Read the comment docs.

mih commented 2 years ago

It seems the full set of fixes required is

diff --git a/datalad_next/gitremote/tests/test_datalad_annex.py b/datalad_next/gitremote/tests/test_datalad_annex.py
index 44be227..fcbdde9 100644
--- a/datalad_next/gitremote/tests/test_datalad_annex.py
+++ b/datalad_next/gitremote/tests/test_datalad_annex.py
@@ -80,7 +80,8 @@ def test_export_remote(dspath, remotepath):

 @with_tempfile
-def _check_push_fetch_cycle(ds, remoteurl, remotepath, localtargetpath):
+@with_tempfile
+def _check_push_fetch_cycle(ds, remoteurl, remotepath, localtargetpath, probepath):
     """Test helper

     - add a dla remote to the dataset
@@ -115,8 +116,9 @@ def _check_push_fetch_cycle(ds, remoteurl, remotepath, localtargetpath):

     # if we are on a sane system, also test recovery from (temporary)
     # push failure. MIH cannot force himself to figure out how to do
-    # this on windows, sorry
-    if not on_windows:
+    # this on windows/crippledFS, sorry
+    probeds = Dataset(probepath).create()
+    if not probeds.repo.is_managed_branch():
         # preserve stat-info for later restore
         stat_records = {}
         # must go reverse to not block chmod'ing of children
@@ -212,7 +214,7 @@ def _check_repush_after_vanish(ds, remoteurl, remotepath):
     dsrepo.call_git(['remote', 'add', 'dla', remoteurl])
     remotepath = Path(remotepath)

-    dsrepo.call_git(['push', 'dla'])
+    dsrepo.call_git(['push', '-u', 'dla', DEFAULT_BRANCH])
     eq_dla_branch_state(dsrepo.get_hexsha(DEFAULT_BRANCH), remotepath)

     # wipe out the remote
@@ -293,7 +295,7 @@ def _check_typeweb(pushtmpl, clonetmpl, export, url, preppath, clonepath):
         'dla',
         pushtmpl.format(**locals()),
     ])
-    ds.repo.call_git(['push', 'dla'])
+    ds.repo.call_git(['push', '-u', 'dla', DEFAULT_BRANCH])
     # must override git-annex security setting for localhost
     with patch.dict(
             "os.environ", {
@@ -322,7 +324,7 @@ def test_submodule_url(servepath, url, workdir):
         if on_windows else
         f'datalad-annex::file://{servepath}?type=directory&directory={{path}}&encryption=none&exporttree=yes',
     ])
-    tobesubds.repo.call_git(['push', 'dla'])
+    tobesubds.repo.call_git(['push', '-u', 'dla', DEFAULT_BRANCH])
     # create a superdataset to register the subds to
     super = Dataset(workdir / 'super').create()
     with patch.dict(
mih commented 2 years ago

Given that this code will be transitioned to datalad-next, the fixes are applied there. https://github.com/datalad/datalad-next/pull/9