@@ -94,19 +94,17 @@ def git_cherry_pick():
94
94
95
95
@pytest .fixture
96
96
def git_config ():
97
- git_config_cmd = 'git' , 'config'
98
- return lambda * extra_args : (
99
- subprocess .run (git_config_cmd + extra_args , check = True )
100
- )
97
+ git_config_cmd = "git" , "config"
98
+ return lambda * extra_args : (subprocess .run (git_config_cmd + extra_args , check = True ))
101
99
102
100
103
101
@pytest .fixture
104
102
def tmp_git_repo_dir (tmpdir , cd , git_init , git_commit , git_config ):
105
103
cd (tmpdir )
106
104
git_init ()
107
- git_config (' --local' , ' user.name' , ' Monty Python' )
108
- git_config (
' --local' , ' user.email' , ' [email protected] ' )
109
- git_commit (' Initial commit' , ' --allow-empty' )
105
+ git_config (" --local" , " user.name" , " Monty Python" )
106
+ git_config (
" --local" , " user.email" , " [email protected] " )
107
+ git_commit (" Initial commit" , " --allow-empty" )
110
108
yield tmpdir
111
109
112
110
@@ -307,16 +305,16 @@ def test_is_not_cpython_repo():
307
305
308
306
309
307
def test_find_config (tmp_git_repo_dir , git_add , git_commit ):
310
- relative_config_path = ' .cherry_picker.toml'
311
- tmp_git_repo_dir .join (relative_config_path ).write (' param = 1' )
308
+ relative_config_path = " .cherry_picker.toml"
309
+ tmp_git_repo_dir .join (relative_config_path ).write (" param = 1" )
312
310
git_add (relative_config_path )
313
- git_commit (' Add config' )
314
- scm_revision = get_sha1_from (' HEAD' )
315
- assert find_config (scm_revision ) == f' { scm_revision } :{ relative_config_path } '
311
+ git_commit (" Add config" )
312
+ scm_revision = get_sha1_from (" HEAD" )
313
+ assert find_config (scm_revision ) == f" { scm_revision } :{ relative_config_path } "
316
314
317
315
318
316
def test_find_config_not_found (tmp_git_repo_dir ):
319
- scm_revision = get_sha1_from (' HEAD' )
317
+ scm_revision = get_sha1_from (" HEAD" )
320
318
assert find_config (scm_revision ) is None
321
319
322
320
@@ -326,16 +324,18 @@ def test_find_config_not_git(tmpdir, cd):
326
324
327
325
328
326
def test_load_full_config (tmp_git_repo_dir , git_add , git_commit ):
329
- relative_config_path = '.cherry_picker.toml'
330
- tmp_git_repo_dir .join (relative_config_path ).write ('''\
327
+ relative_config_path = ".cherry_picker.toml"
328
+ tmp_git_repo_dir .join (relative_config_path ).write (
329
+ """\
331
330
team = "python"
332
331
repo = "core-workfolow"
333
332
check_sha = "5f007046b5d4766f971272a0cc99f8461215c1ec"
334
333
default_branch = "devel"
335
- ''' )
334
+ """
335
+ )
336
336
git_add (relative_config_path )
337
- git_commit (' Add config' )
338
- scm_revision = get_sha1_from (' HEAD' )
337
+ git_commit (" Add config" )
338
+ scm_revision = get_sha1_from (" HEAD" )
339
339
cfg = load_config (None )
340
340
assert cfg == (
341
341
scm_revision + ":" + relative_config_path ,
@@ -350,13 +350,15 @@ def test_load_full_config(tmp_git_repo_dir, git_add, git_commit):
350
350
351
351
352
352
def test_load_partial_config (tmp_git_repo_dir , git_add , git_commit ):
353
- relative_config_path = '.cherry_picker.toml'
354
- tmp_git_repo_dir .join (relative_config_path ).write ('''\
353
+ relative_config_path = ".cherry_picker.toml"
354
+ tmp_git_repo_dir .join (relative_config_path ).write (
355
+ """\
355
356
repo = "core-workfolow"
356
- ''' )
357
+ """
358
+ )
357
359
git_add (relative_config_path )
358
- git_commit (' Add config' )
359
- scm_revision = get_sha1_from (' HEAD' )
360
+ git_commit (" Add config" )
361
+ scm_revision = get_sha1_from (" HEAD" )
360
362
cfg = load_config (relative_config_path )
361
363
assert cfg == (
362
364
f"{ scm_revision } :{ relative_config_path } " ,
@@ -454,25 +456,25 @@ def test_from_git_rev_read_negative(input_path, tmp_git_repo_dir):
454
456
455
457
456
458
def test_from_git_rev_read_uncommitted (tmp_git_repo_dir , git_add , git_commit ):
457
- some_text = ' blah blah π€'
458
- relative_file_path = ' .some.file'
459
- (
460
- pathlib . Path ( tmp_git_repo_dir ) / relative_file_path
461
- ). write_text ( some_text , encoding = 'utf-8' )
462
- git_add ('.' )
459
+ some_text = " blah blah π€"
460
+ relative_file_path = " .some.file"
461
+ (pathlib . Path ( tmp_git_repo_dir ) / relative_file_path ). write_text (
462
+ some_text , encoding = "utf-8"
463
+ )
464
+ git_add ("." )
463
465
with pytest .raises (ValueError ):
464
466
from_git_rev_read ("HEAD:" + relative_file_path ) == some_text
465
467
466
468
467
469
def test_from_git_rev_read (tmp_git_repo_dir , git_add , git_commit ):
468
- some_text = ' blah blah π€'
469
- relative_file_path = ' .some.file'
470
- (
471
- pathlib . Path ( tmp_git_repo_dir ) / relative_file_path
472
- ). write_text ( some_text , encoding = 'utf-8' )
473
- git_add ('.' )
474
- git_commit (' Add some file' )
475
- assert from_git_rev_read (' HEAD:' + relative_file_path ) == some_text
470
+ some_text = " blah blah π€"
471
+ relative_file_path = " .some.file"
472
+ (pathlib . Path ( tmp_git_repo_dir ) / relative_file_path ). write_text (
473
+ some_text , encoding = "utf-8"
474
+ )
475
+ git_add ("." )
476
+ git_commit (" Add some file" )
477
+ assert from_git_rev_read (" HEAD:" + relative_file_path ) == some_text
476
478
477
479
478
480
def test_states (tmp_git_repo_dir ):
0 commit comments