def __0_25_1(conf: GitConfigParser, repo: Repo, console: Console): """ Until v0.25.1 inclusive, bossman init changed the git config to add explicit push/fetch refspecs to force git pull/push to also fetch/push notes. This behaviour was changed in favour of an explicit pull and push as part of application logic when relevant (e.g. before bossman status/prerelease/release, before an after bossman apply). The change was largely motivated by the fact that adding the fetch/push refspecs to the config appears to break normal branch tracking, forcing an explicit `git push origin ref`, not great UX. Because notes are critical to bossman, it's also better not to rely on the user remembering to push after apply. """ notes_refspec = "+refs/notes/*:refs/notes/*" for section in conf.sections(): if section.startswith("remote"): push_refspecs = conf.get_values(section, "push", []) if notes_refspec in push_refspecs: conf.remove_option(section, "push") push_refspecs = list(refspec for refspec in push_refspecs if refspec != notes_refspec) for refspec in push_refspecs: conf.add_value(section, "push", refspec) console.print(r"[red]-[/] \[{}] push: {}".format( section, notes_refspec)) fetch_refspecs = conf.get_values(section, "fetch", []) if notes_refspec in fetch_refspecs: conf.remove_option(section, "fetch") fetch_refspecs = list(refspec for refspec in fetch_refspecs if refspec != notes_refspec) for refspec in fetch_refspecs: conf.add_value(section, "fetch", refspec) console.print(r"[red]-[/] \[{}] fetch: {}".format( section, notes_refspec))
def test_single_to_multiple(self): file_obj = self._to_memcache(fixture_path('git_config_multiple')) with GitConfigParser(file_obj, read_only=False) as cw: cw.add_value('section1', 'other_option1', 'other_value1a') cw.write() file_obj.seek(0) cr = GitConfigParser(file_obj, read_only=True) self.assertEqual(cr.get_value('section1', 'option1'), 'value1b') self.assertEqual(cr.get_values('section1', 'option1'), ['value1a', 'value1b']) self.assertEqual(cr.get_value('section1', 'other_option1'), 'other_value1a') self.assertEqual(cr.get_values('section1', 'other_option1'), ['other_value1', 'other_value1a']) self.assertEqual(cr.items('section1'), [('option1', 'value1b'), ('other_option1', 'other_value1a')]) self.assertEqual( cr.items_all('section1'), [('option1', ['value1a', 'value1b']), ('other_option1', ['other_value1', 'other_value1a'])])