Esempio n. 1
0
    def test_git_flow_repo_with_new_config_includes_fix(self):
        """ Test with git flow option, entries appear for new fixes """

        w("""
            cat <<EOF > .gitchangelog.rc

include_merges = False
git_flow = True

EOF
            ## Hotfix Branch
            git checkout -b fix/long_fix_1

            ## Hack on fix
            git commit -m 'fix: bug x' \
                --author 'Monty <*****@*****.**>' \
                --date '2000-01-08 11:00:00' \
                --allow-empty

            ## Fix done, merge back, assume fast-forward wasn't possible
            git checkout master
            git merge --no-ff --commit fix/long_fix_1

        """)
        changelog = w('$tprog')

        ## The changelog should have a record of this new fix
        self.assert_contains(changelog, "long fix 1")
Esempio n. 2
0
    def setUp(self):
        super(TestLogLinearbility, self).setUp()

        ## Target tree:
        ##
        ## (Pdb) print w("git log --all --pretty=tformat:%s\ %d --graph")
        ## * new: commit on develop branch  (HEAD, tag: 0.0.3, develop)
        ## * fix: something  (tag: 0.0.2)
        ## * first commit  (tag: 0.0.1, master)

        w("""

            git commit -m 'first commit' --allow-empty
            git tag 0.0.1

            ## Branch
            git checkout -b develop

            git commit -m 'fix: something' --allow-empty
            git tag 0.0.2

            git commit -m 'new: commit on develop branch' --allow-empty
            git tag 0.0.3

        """)
Esempio n. 3
0
    def test_reuse_options(self):
        """We must be able to define a small gitchangelog.rc that adjust only
        one variable of all the builtin defaults."""

        w("""cat <<EOF > .gitchangelog.rc

ignore_regexps += [r'XXX', ]

EOF
        """)
        changelog = w('$tprog')
        self.assert_not_contains(
            changelog,
            "XXX",
            msg="Should not contain commit with XXX in it... "
            "content of changelog:\n%s" % changelog)
        self.assert_contains(
            changelog,
            "dd file ``e``",
            msg="Should contain at least a message of other commits... "
            "content of changelog:\n%s" % changelog)
        self.assert_not_contains(
            changelog,
            "!minor",
            msg="Shouldn't contain !minor tagged commit neither... "
            "content of changelog:\n%s" % changelog)
Esempio n. 4
0
    def setUp(self):
        super(TestLogLinearbility, self).setUp()

        ## Target tree:
        ##
        ## (Pdb) print w("git log --all --pretty=tformat:%s\ %d --graph")
        ## * new: commit on develop branch  (HEAD, tag: 0.0.3, develop)
        ## * fix: something  (tag: 0.0.2)
        ## * first commit  (tag: 0.0.1, master)

        w("""

            git commit -m 'first commit' --allow-empty
            git tag 0.0.1

            ## Branch
            git checkout -b develop

            git commit -m 'fix: something' --allow-empty
            git tag 0.0.2

            git commit -m 'new: commit on develop branch' --allow-empty
            git tag 0.0.3

        """)
Esempio n. 5
0
    def test_unexistent_template_name(self):
        """Reference implementation should match mustache and mako implem"""

        w("""cat <<EOF > .gitchangelog.rc

output_engine = mustache('doesnotexist')

EOF
        """)
        out, err, errlvl = cmd('$tprog')
        self.assertEqual(
            errlvl, 1,
            msg="Should fail as template does not exist")
        self.assertEqual(
            out, "",
            msg="No stdout was expected since there was an error. "
            "Current stdout:\n%r" % out)
        self.assertContains(
            err, "doesnotexist",
            msg="There should be an error message mentioning 'doesnotexist'. "
            "Current stderr:\n%s" % err)
        self.assertContains(
            err, "restructuredtext",
            msg="The error message should mention 'available'. "
            "Current stderr:\n%s" % err)
        self.assertContains(
            err, "mustache",
            msg="The error message should mention 'mustache'. "
            "Current stderr:\n%s" % err)
        self.assertContains(
            err, "restructuredtext",
            msg="The error message should mention 'restructuredtext'. "
            "Current stderr:\n%s" % err)
Esempio n. 6
0
    def test_provided_templates(self):
        """Run all provided templates at least once"""

        for label, directory in [("makotemplate", "mako"),
                                 ("mustache", "mustache")]:
            template_dir = os.path.join(
                os.path.dirname(os.path.realpath(__file__)), "..", "templates",
                directory)
            templates = glob.glob(os.path.join(template_dir, "*.tpl"))
            template_labels = [
                os.path.basename(f).split(".")[0] for f in templates
            ]
            for tpl in template_labels:
                w("""cat <<EOF > .gitchangelog.rc

output_engine = %s(%r)

EOF
                """ % (label, tpl))
                out, err, errlvl = cmd('$tprog')
                self.assertEqual(errlvl,
                                 0,
                                 msg="Should not fail on %s(%r) " %
                                 (label, tpl) +
                                 "Current stderr:\n%s" % indent(err))
Esempio n. 7
0
    def test_git_flow_repo_with_new_config_includes_fix(self):
        """ Test with git flow option, entries appear for new fixes """

        w("""
            cat <<EOF > .gitchangelog.rc

include_merges = False
git_flow = True

EOF
            ## Hotfix Branch
            git checkout -b fix/long_fix_1

            ## Hack on fix
            git commit -m 'fix: bug x' \
                --author 'Monty <*****@*****.**>' \
                --date '2000-01-08 11:00:00' \
                --allow-empty

            ## Fix done, merge back, assume fast-forward wasn't possible
            git checkout master
            git merge --no-ff --commit fix/long_fix_1

        """)
        changelog = w('$tprog')

        ## The changelog should have a record of this new fix
        self.assert_contains(changelog, "long fix 1")
Esempio n. 8
0
def module_process(ianadir, host, days, ipv6=False, bestonly=False):
        """
        Match BGP prefixes in IANA's directory and generate text
        outputs and stats that determine average active prefix counts
        and average de-aggregation for each RIR.

        :param IanaDirectory ianadir: IanaDirectory instance to match agains
        :param str host: Host to take BGP feeds from
        :param days: List of days to analyze
        :param bool ipv6: IPv6 flag
        :param bool bestonly: Take only best BGP paths into account
        """

        timeline=[]
        timelineavg=[]

        for t in days:
                rirpfxlens={}
                ifn = bgp.bgpdump_pickle(t, host, ipv6)
                if not ifn:
                        continue
                bgpdump=common.load_pickle(ifn)
                common.d("ianaspace.module_run: matching prefixes in a tree (%d)"%len(bgpdump))

                for pv in bgpdump:
                        if bestonly and not (pv[0] and '>' in pv[0]):
                                continue

                        net = ipaddr.IPNetwork(pv[1])
                        r=ianadir.resolve_network(net)
                        if not r:
                                common.w("No IANA assignment for", str(pv[1]))
                                continue
                        name=r[2]
                        if r[1] == 'LEGACY' and not name in RIRS:
                                name='LEGACY'
                        if not name in rirpfxlens:
                                rirpfxlens[name]=[]
                        rirpfxlens[name].append(net.prefixlen)
                timeline.append([str(t)]+[len(rirpfxlens[n]) for n in RIRS])
                timelineavg.append([str(t)]+[(reduce(lambda x, y: x + y, rirpfxlens[n])/
                                             float(len(rirpfxlens[n]))) for n in RIRS])

                outtxt = '%s/rirstats%d-%s.txt'%(common.resultdir(t), (6 if ipv6 else 4), host)
                common.d("Generating output RIR stats text "+outtxt)
                with open(outtxt,'w') as f:
                        for i,k in enumerate(RIRS):
                                f.write('%s: %d (avg pfxlen: %.2f)\n'%(str(k), timeline[-1][1+i],
                                                                       round(timelineavg[-1][1+i], 2)))

        if timeline:
                outgraph = '%s/rirpfxcount%d-%s'%(common.resultdir(), (6 if ipv6 else 4), host)
                common.d("Generating output RIR pfxcount graph with prefix "+outgraph)
                graph.gen_multilineplot(timeline, outgraph, legend=RIRS, ylabel='Pfx count')

        if timelineavg:
                outgraph = '%s/rirpfxlen%d-%s'%(common.resultdir(), (6 if ipv6 else 4), host)
                common.d("Generating output RIR pfxlen graph with prefix "+outgraph)
                graph.gen_multilineplot(timelineavg, outgraph, legend=RIRS, ylabel='Avg pfx len')
Esempio n. 9
0
    def test_tags(self):
        """ Test that all tags in branch history make it into changelog """

        w("""

#            Target tree:
#
#            * bd474af (HEAD, tag: 0.0.7)
#            *   e4e3d60 Merge branch 'master' into test_tags
#            |\
#            | * ae1baa0 (tag: 0.0.6, master) fix: hotfix on master
#            |/
#            * 42e63da commit on develop branch
#            * 42e65da (tag: 0.0.5) commit on develop branch

            ## Branch
            git checkout master
            git tag 0.0.4
            git checkout -b test_tags

            ## Build the tree
            git commit -m 'commit on develop branch' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-07 11:00:00' \
                --allow-empty

            git tag 0.0.5

            git commit -m 'commit on develop branch' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-08 11:00:00' \
                --allow-empty

           git checkout master

            git commit -m 'fix: hotfix on master' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-11 11:00:00' \
                --allow-empty

            git tag 0.0.6

            git checkout test_tags
            git merge master
            git tag 0.0.7

        """)
        changelog = w('$tprog')
        self.assert_contains(
            changelog,
            "0.0.6",
            msg=
            "Missing a tag (0.0.6) that is located in a branch that was merged into HEAD... "
            "content of changelog:\n%s" % changelog)
Esempio n. 10
0
    def test_tags(self):
        """ Test that all tags in branch history make it into changelog """

        w("""

#            Target tree:
#
#            * bd474af (HEAD, tag: 0.0.7)
#            *   e4e3d60 Merge branch 'master' into test_tags
#            |\
#            | * ae1baa0 (tag: 0.0.6, master) fix: hotfix on master
#            |/
#            * 42e63da commit on develop branch
#            * 42e65da (tag: 0.0.5) commit on develop branch

            ## Branch
            git checkout master
            git tag 0.0.4
            git checkout -b test_tags

            ## Build the tree
            git commit -m 'commit on develop branch' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-07 11:00:00' \
                --allow-empty

            git tag 0.0.5

            git commit -m 'commit on develop branch' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-08 11:00:00' \
                --allow-empty

           git checkout master

            git commit -m 'fix: hotfix on master' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-11 11:00:00' \
                --allow-empty

            git tag 0.0.6

            git checkout test_tags
            git merge master
            git tag 0.0.7

        """)
        changelog = w('$tprog')
        self.assert_contains(
            changelog, "0.0.6",
            msg="Missing a tag (0.0.6) that is located in a branch that was merged into HEAD... "
            "content of changelog:\n%s" % changelog)
Esempio n. 11
0
    def test_git_flow_skips_normal_merges(self):
        """ Test the git flow option doesn't introduce merge commits other than features and bug fixes """

        w("""
            cat <<EOF > .gitchangelog.rc

include_merges = False
git_flow = True

EOF
            ## Feature Branch
            git checkout -b feature/long_feature_1

            ## Hack on feature
            git commit -m 'new: started feature x' --author 'Monty <*****@*****.**>' \
                --date '2000-01-08 11:00:00' --allow-empty

            git commit -m 'fix: something i broke in x' --author 'Monty <*****@*****.**>' \
                --date '2000-01-09 11:00:00' --allow-empty

            ## Progress made directly on the ancestor branch
            git checkout master
            git commit -m 'chg: i made lots of progress' --author 'Monty <*****@*****.**>' \
                --date '2000-01-10 11:00:00' --allow-empty

            ## Merge that progress into the feature branch
            git checkout feature/long_feature_1
            git merge --no-ff --commit master

            ## Feature done, merge back, assume fast-forward wasn't possible
            git checkout master
            git merge --no-ff --commit feature/long_feature_1

            ## Fictional non-feature merge into master
            git commit -m 'Merge branch \'develop\' into master' --allow-empty

            ## What if the user merges a tag?
            git commit -m 'Merge tag 2.0 into master' --allow-empty

        """)
        changelog = w('$tprog')

        ## The changelog should have a record of this newly added feature
        self.assert_contains(changelog, "long feature 1")

        ## There better not be any tag merges
        self.assert_not_contains(changelog, "Merge tag")

        ## But it shouldn't show us the intermediary merge of master into feature
        self.assert_not_contains(changelog, "master")
Esempio n. 12
0
    def test_git_flow_skips_normal_merges(self):
        """ Test the git flow option doesn't introduce merge commits other than features and bug fixes """

        w("""
            cat <<EOF > .gitchangelog.rc

include_merges = False
git_flow = True

EOF
            ## Feature Branch
            git checkout -b feature/long_feature_1

            ## Hack on feature
            git commit -m 'new: started feature x' --author 'Monty <*****@*****.**>' \
                --date '2000-01-08 11:00:00' --allow-empty

            git commit -m 'fix: something i broke in x' --author 'Monty <*****@*****.**>' \
                --date '2000-01-09 11:00:00' --allow-empty

            ## Progress made directly on the ancestor branch
            git checkout master
            git commit -m 'chg: i made lots of progress' --author 'Monty <*****@*****.**>' \
                --date '2000-01-10 11:00:00' --allow-empty

            ## Merge that progress into the feature branch
            git checkout feature/long_feature_1
            git merge --no-ff --commit master

            ## Feature done, merge back, assume fast-forward wasn't possible
            git checkout master
            git merge --no-ff --commit feature/long_feature_1

            ## Fictional non-feature merge into master
            git commit -m 'Merge branch \'develop\' into master' --allow-empty

            ## What if the user merges a tag?
            git commit -m 'Merge tag 2.0 into master' --allow-empty

        """)
        changelog = w('$tprog')

        ## The changelog should have a record of this newly added feature
        self.assert_contains(changelog, "long feature 1")

        ## There better not be any tag merges
        self.assert_not_contains(changelog, "Merge tag")

        ## But it shouldn't show us the intermediary merge of master into feature
        self.assert_not_contains(changelog, "master")
Esempio n. 13
0
    def test_init_file_already_exists(self):

        w("touch .gitchangelog.rc")
        out, err, errlvl = cmd('$tprog init')
        self.assertEqual(
            errlvl, 1,
            msg="Should fail to init on simple git repository")
        self.assertContains(
            err, "exists",
            msg="There should be a error msg mentioning the file exists. "
            "Current stderr:\n%r" % err)
        self.assertEqual(
            out, "",
            msg="No standard output message expected in case of error "
            "Current stdout:\n%s" % out)
Esempio n. 14
0
 def test_config_file_is_not_a_file(self):
     w("""
         mkdir .gitchangelog.rc
     """)
     out, err, errlvl = cmd('$tprog')
     self.assertEqual(
         errlvl, 1,
         msg="Should fail when bogus config file exists but is not a file")
     self.assertContains(
         err, "not a file",
         msg="There should be a error message stating that config file is not a file."
         "Current stderr:\n%r" % err)
     self.assertEqual(
         out, "",
         msg="There should be no standard output. "
         "Current stdout:\n%s" % out)
Esempio n. 15
0
    def test_init_file_already_exists(self):

        w("touch .gitchangelog.rc")
        out, err, errlvl = cmd('$tprog init')
        self.assertEqual(errlvl,
                         1,
                         msg="Should fail to init on simple git repository")
        self.assert_contains(
            err,
            "exists",
            msg="There should be a error msg mentioning the file exists. "
            "Current stderr:\n%r" % err)
        self.assertEqual(
            out,
            "",
            msg="No standard output message expected in case of error "
            "Current stdout:\n%s" % out)
Esempio n. 16
0
    def setUp(self):
        super(TestCrossBranchTags, self).setUp()

        ## Target tree:
        ##
        ## (Pdb) print w("git log --all --pretty=tformat:%s\ %d --graph")
        ## * c  (HEAD, master)
        ## * b
        ## * a

        w("""

            git commit -m 'a' --allow-empty
            git commit -m 'b' --allow-empty
            git commit -m 'c' --allow-empty

        """)
Esempio n. 17
0
    def setUp(self):
        super(TestCrossBranchTags, self).setUp()

        ## Target tree:
        ##
        ## (Pdb) print w("git log --all --pretty=tformat:%s\ %d --graph")
        ## * c  (HEAD, master)
        ## * b
        ## * a

        w("""

            git commit -m 'a' --allow-empty
            git commit -m 'b' --allow-empty
            git commit -m 'c' --allow-empty

        """)
Esempio n. 18
0
 def test_simple_run(self):
     changelog = w('$tprog')
     self.assertEqual(
         changelog, self.REFERENCE,
         msg="Should match our reference output... "
         "diff of changelogs:\n%s"
         % '\n'.join(difflib.unified_diff(changelog.split("\n"),
                                          self.REFERENCE.split("\n"),
                                          lineterm="")))
Esempio n. 19
0
 def test_simple_run(self):
     changelog = w('$tprog')
     self.assertEqual(changelog,
                      self.REFERENCE,
                      msg="Should match our reference output... "
                      "diff of changelogs:\n%s" % '\n'.join(
                          difflib.unified_diff(changelog.split("\n"),
                                               self.REFERENCE.split("\n"),
                                               lineterm="")))
Esempio n. 20
0
    def test_git_flow_repo_with_default_config_skips_features(self):
        """ Test without git flow option, no entries appear for new features """

        w("""
            cat <<EOF > .gitchangelog.rc

include_merges = False
git_flow = False

EOF
            ## Feature Branch
            git checkout -b feature/long_feature_1

            ## Hack on feature
            git commit -m 'new: started feature x' \
                --author 'Monty <*****@*****.**>' \
                --date '2000-01-08 11:00:00' \
                --allow-empty

            git commit -m 'fix: something i broke in x' \
                --author 'Monty <*****@*****.**>' \
                --date '2000-01-09 11:00:00' \
                --allow-empty

            ## Feature done, merge back, assume fast-forward wasn't possible
            git checkout master
            git merge --no-ff --commit feature/long_feature_1

        """)
        changelog = w('$tprog')

        ## The changelog should have no record of this newly added feature
        self.assert_not_contains(changelog, "feature x")
        self.assert_not_contains(changelog, "long_feature_1")
        self.assert_not_contains(changelog, "long feature 1")
        self.assertEqual(
            changelog,
            self.REFERENCE,
            msg=
            'Should match our reference output... diff from what it should be:\n%s'
            % '\n'.join(
                difflib.unified_diff(self.REFERENCE.split('\n'),
                                     changelog.split('\n'),
                                     lineterm='')))
Esempio n. 21
0
    def test_git_flow_hotfix_branch(self):
        """ Test the git flow option counts hotfixes as fixes """

        w("""
            cat <<EOF > .gitchangelog.rc

include_merges = False
git_flow = True

EOF
            ## Instead of creating a real git history, I find it easier to fake the merges
            git commit -m 'Merge branch hotfix/ticket-123_red_button into develop' --allow-empty

        """)
        changelog = w('$tprog')

        ## The changelog should have properly formatted text for both
        self.assert_contains(changelog, "Fixed ticket-123 red button")
        self.assert_not_contains(changelog, "into develop")
Esempio n. 22
0
    def test_in_bare_repository(self):
        w("""

            cd ..
            git clone --bare repos test_bare

        """)
        out, err, errlvl = cmd('cd ../test_bare && $tprog init')
        self.assertEqual(
            errlvl, 1,
            msg="Should fail to init outside a git repository.")
        self.assertContains(
            err, "bare",
            msg="There should be a error msg mentioning 'bare'. "
            "Current stderr:\n%r" % err)
        self.assertEqual(
            out, "",
            msg="No standard output message expected. "
            "Current stdout:\n%s" % out)
Esempio n. 23
0
    def setUp(self):
        super(TestLogHardLinearbility, self).setUp()

        ##  Target tree:
        ##
        ## (Pdb) print w("git log --all --pretty=tformat:%s\ %d --graph")
        ## * new: something  (HEAD, tag: 0.2, develop)
        ## *   Merge tag '0.1.1' into develop
        ## |\
        ## | * fix: out-of-band hotfix  (tag: 0.1.1)
        ## * | chg: continued development
        ## |/
        ## * fix: something  (tag: 0.1)
        ## * first commit  (tag: 0.0.1, master)
        ##

        w("""

            git commit -m 'first commit' --allow-empty
            git tag 0.0.1

            ## Branch
            git checkout -b develop

            ## Build the tree
            git commit -m 'fix: something' --allow-empty
            git tag 0.1

            git commit -m 'chg: continued development' --allow-empty

            git checkout 0.1

            git commit -m 'fix: out-of-band hotfix' --allow-empty
            git tag 0.1.1

            git checkout develop

            git merge 0.1.1

            git commit -m 'new: something' --allow-empty
            git tag 0.2

        """)
Esempio n. 24
0
    def test_git_flow_hotfix_branch(self):
        """ Test the git flow option counts hotfixes as fixes """

        w("""
            cat <<EOF > .gitchangelog.rc

include_merges = False
git_flow = True

EOF
            ## Instead of creating a real git history, I find it easier to fake the merges
            git commit -m 'Merge branch hotfix/ticket-123_red_button into develop' --allow-empty

        """)
        changelog = w('$tprog')

        ## The changelog should have properly formatted text for both
        self.assert_contains(changelog, "Fixed ticket-123 red button")
        self.assert_not_contains(changelog, "into develop")
Esempio n. 25
0
    def setUp(self):
        super(TestLogHardLinearbility, self).setUp()

        ##  Target tree:
        ##
        ## (Pdb) print w("git log --all --pretty=tformat:%s\ %d --graph")
        ## * new: something  (HEAD, tag: 0.2, develop)
        ## *   Merge tag '0.1.1' into develop 
        ## |\  
        ## | * fix: out-of-band hotfix  (tag: 0.1.1)
        ## * | chg: continued development 
        ## |/  
        ## * fix: something  (tag: 0.1)
        ## * first commit  (tag: 0.0.1, master)
        ## 

        w("""

            git commit -m 'first commit' --allow-empty
            git tag 0.0.1

            ## Branch
            git checkout -b develop

            ## Build the tree
            git commit -m 'fix: something' --allow-empty
            git tag 0.1

            git commit -m 'chg: continued development' --allow-empty

            git checkout 0.1

            git commit -m 'fix: out-of-band hotfix' --allow-empty
            git tag 0.1.1

            git checkout develop

            git merge 0.1.1

            git commit -m 'new: something' --allow-empty
            git tag 0.2

        """)
Esempio n. 26
0
    def test_overriding_options(self):
        """We must be able to define a small gitchangelog.rc that adjust only
        one variable of all the builtin defaults."""

        w("""

            cat <<EOF > .gitchangelog.rc

tag_filter_regexp = r'^v[0-9]+\\.[0.9]$'

EOF
            git tag 'v7.0' HEAD^
            git tag 'v8.0' HEAD

        """)
        changelog = w('$tprog')
        self.assertContains(
            changelog, "v8.0",
            msg="At least one of the tags should be displayed in changelog... "
            "content of changelog:\n%s" % changelog)
Esempio n. 27
0
    def test_in_bare_repository(self):
        w("""

            cd ..
            git clone --bare repos test_bare

        """)
        out, err, errlvl = cmd('cd ../test_bare && $tprog init')
        self.assertEqual(errlvl,
                         1,
                         msg="Should fail to init outside a git repository.")
        self.assert_contains(
            err,
            "bare",
            msg="There should be a error msg mentioning 'bare'. "
            "Current stderr:\n%r" % err)
        self.assertEqual(out,
                         "",
                         msg="No standard output message expected. "
                         "Current stdout:\n%s" % out)
Esempio n. 28
0
    def test_in_sub_repository(self):
        w("""

            mkdir subdir
            cd subdir

        """)
        out, err, errlvl = cmd('$tprog init')
        self.assertEqual(errlvl, 0, msg="Should not fail in sub directory.")
        self.assert_contains(
            out,
            "created",
            msg="There should  msg mentioning the file was 'created'. "
            "Current stdout:\n%r" % out)
        self.assertEqual(err,
                         "",
                         msg="No error message expected. "
                         "Current stderr:\n%s" % err)
        self.assertTrue(os.path.exists('.gitchangelog.rc'),
                        msg="File must have been created.")
Esempio n. 29
0
    def setUp(self):
        super(TestCrossBranchTags, self).setUp()

        ## Target tree:
        ##
        ## (Pdb) print w("git log --all --pretty=tformat:%s\ %d --graph")
        ## *   Merge branch 'master' into develop  (HEAD, tag: 0.0.4, develop)
        ## |\
        ## | * new: some new commit  (master)
        ## | * fix: hotfix on master  (tag: 0.0.3)
        ## * | new: second commit on develop branch
        ## * | new: first commit on develop branch  (tag: 0.0.2)
        ## |/
        ## * first commit  (tag: 0.0.1)

        w("""

            git commit -m 'first commit' --allow-empty
            git tag 0.0.1

            ## We are on master branch by default...
            ## commit, tag
            git checkout -b develop
            git commit -m 'new: first commit on develop branch' --allow-empty
            git tag 0.0.2

            git commit -m 'new: second commit on develop branch' --allow-empty

            ## Back on master, commit tag
            git checkout master
            git commit -m 'fix: hotfix on master' --allow-empty
            git tag 0.0.3

            git commit -m 'new: some new commit' --allow-empty

            ## Merge and tag
            git checkout develop
            git merge master --no-ff
            git tag 0.0.4

        """)
Esempio n. 30
0
    def setUp(self):
        super(TestCrossBranchTags, self).setUp()

        ## Target tree:
        ##
        ## (Pdb) print w("git log --all --pretty=tformat:%s\ %d --graph")
        ## *   Merge branch 'master' into develop  (HEAD, tag: 0.0.4, develop)
        ## |\
        ## | * new: some new commit  (master)
        ## | * fix: hotfix on master  (tag: 0.0.3)
        ## * | new: second commit on develop branch
        ## * | new: first commit on develop branch  (tag: 0.0.2)
        ## |/
        ## * first commit  (tag: 0.0.1)

        w("""

            git commit -m 'first commit' --allow-empty
            git tag 0.0.1

            ## We are on master branch by default...
            ## commit, tag
            git checkout -b develop
            git commit -m 'new: first commit on develop branch' --allow-empty
            git tag 0.0.2

            git commit -m 'new: second commit on develop branch' --allow-empty

            ## Back on master, commit tag
            git checkout master
            git commit -m 'fix: hotfix on master' --allow-empty
            git tag 0.0.3

            git commit -m 'new: some new commit' --allow-empty

            ## Merge and tag
            git checkout develop
            git merge master --no-ff
            git tag 0.0.4

        """)
Esempio n. 31
0
    def test_overriding_options(self):
        """We must be able to define a small gitchangelog.rc that adjust only
        one variable of all the builtin defaults."""

        w("""

            cat <<EOF > .gitchangelog.rc

tag_filter_regexp = r'^v[0-9]+\.[0.9]$'

EOF
            git tag 'v7.0' HEAD^
            git tag 'v8.0' HEAD

        """)
        changelog = w('$tprog')
        self.assert_contains(
            changelog,
            "v8.0",
            msg="At least one of the tags should be displayed in changelog... "
            "content of changelog:\n%s" % changelog)
Esempio n. 32
0
    def test_include_merge_options(self):
        """We must be able to define a small gitchangelog.rc that adjust only
        one variable of all the builtin defaults."""

        w("""cat <<EOF > .gitchangelog.rc

include_merge = False

EOF

            git checkout -b develop
            git commit -m "made on develop branch" --allow-empty
            git checkout master
            git merge develop --no-ff

        """)
        changelog = w('$tprog')
        self.assertNotContains(
            changelog, "Merge",
            msg="Should not contain commit with 'Merge' in it... "
            "content of changelog:\n%s" % changelog)
Esempio n. 33
0
    def test_with_filename_same_as_tag(self):
        w("""

            touch 0.0.1

        """)
        out, err, errlvl = cmd('$tprog')
        self.assertEqual(
            errlvl, 0,
            msg="Should not fail even if filename same as tag name.")
        self.assertEqual(
            err, "",
            msg="No error message expected. "
            "Current stderr:\n%s" % err)
        self.assertEqual(
            out, self.REFERENCE,
            msg="Should match our reference output... "
            "diff of changelogs:\n%s"
            % '\n'.join(difflib.unified_diff(out.split("\n"),
                                             self.REFERENCE.split("\n"),
                                             lineterm="")))
Esempio n. 34
0
    def test_git_flow_repo_with_default_config_skips_features(self):
        """ Test without git flow option, no entries appear for new features """

        w("""
            cat <<EOF > .gitchangelog.rc

include_merges = False
git_flow = False

EOF
            ## Feature Branch
            git checkout -b feature/long_feature_1

            ## Hack on feature
            git commit -m 'new: started feature x' \
                --author 'Monty <*****@*****.**>' \
                --date '2000-01-08 11:00:00' \
                --allow-empty

            git commit -m 'fix: something i broke in x' \
                --author 'Monty <*****@*****.**>' \
                --date '2000-01-09 11:00:00' \
                --allow-empty

            ## Feature done, merge back, assume fast-forward wasn't possible
            git checkout master
            git merge --no-ff --commit feature/long_feature_1

        """)
        changelog = w('$tprog')

        ## The changelog should have no record of this newly added feature
        self.assert_not_contains(changelog, "feature x")
        self.assert_not_contains(changelog, "long_feature_1")
        self.assert_not_contains(changelog, "long feature 1")
        self.assertEqual(changelog, self.REFERENCE,
                         msg='Should match our reference output... diff from what it should be:\n%s' %
                             '\n'.join(
                             difflib.unified_diff(self.REFERENCE.split('\n'), changelog.split('\n'),
                                                  lineterm='')))
Esempio n. 35
0
    def test_same_output_with_different_engine(self):
        """Reference implementation should match mustache and mako implem"""

        w("""cat <<EOF > .gitchangelog.rc

output_engine = mustache('restructuredtext')

EOF
        """)
        changelog = w('$tprog')
        self.assertEqual(
            changelog,
            self.REFERENCE,
            msg="Mustache output should match our reference output... "
            "diff of changelogs:\n%s" % '\n'.join(
                difflib.unified_diff(self.REFERENCE.split("\n"),
                                     changelog.split("\n"),
                                     lineterm="")))

        w("""cat <<EOF > .gitchangelog.rc

output_engine = makotemplate('restructuredtext')

EOF
        """)
        changelog = w('$tprog')
        self.assertEqual(
            changelog,
            self.REFERENCE,
            msg="Mako output should match our reference output... "
            "diff of changelogs:\n%s" % '\n'.join(
                difflib.unified_diff(self.REFERENCE.split("\n"),
                                     changelog.split("\n"),
                                     lineterm="")))
Esempio n. 36
0
    def test_same_output_with_different_engine_incr(self):
        """Reference implementation should match mustache and mako implem"""

        w("""cat <<EOF > .gitchangelog.rc

output_engine = mustache('restructuredtext')

EOF
        """)
        changelog = w('$tprog show 0.0.2..0.0.3')
        self.assertEqual(
            changelog, self.INCR_REFERENCE_002_003,
            msg="Mustache output should match our reference output... "
            "diff of changelogs:\n%s"
            % '\n'.join(difflib.unified_diff(self.INCR_REFERENCE_002_003.split("\n"),
                                             changelog.split("\n"),
                                             lineterm="")))

        w("""cat <<EOF > .gitchangelog.rc

output_engine = makotemplate('restructuredtext')

EOF
        """)
        changelog = w('$tprog show 0.0.2..0.0.3')
        self.assertEqual(
            changelog, self.INCR_REFERENCE_002_003,
            msg="Mako output should match our reference output... "
            "diff of changelogs:\n%s"
            % '\n'.join(difflib.unified_diff(self.INCR_REFERENCE_002_003.split("\n"),
                                             changelog.split("\n"),
                                             lineterm="")))
Esempio n. 37
0
    def test_with_filename_same_as_tag(self):
        w("""

            touch 0.0.1

        """)
        out, err, errlvl = cmd('$tprog')
        self.assertEqual(
            errlvl,
            0,
            msg="Should not fail even if filename same as tag name.")
        self.assertEqual(err,
                         "",
                         msg="No error message expected. "
                         "Current stderr:\n%s" % err)
        self.assertEqual(
            out,
            self.REFERENCE,
            msg="Should match our reference output... "
            "diff of changelogs:\n%s" % '\n'.join(
                difflib.unified_diff(
                    out.split("\n"), self.REFERENCE.split("\n"), lineterm="")))
Esempio n. 38
0
    def test_in_sub_repository(self):
        w("""

            mkdir subdir
            cd subdir

        """)
        out, err, errlvl = cmd('$tprog init')
        self.assertEqual(
            errlvl, 0,
            msg="Should not fail in sub directory.")
        self.assertContains(
            out, "created",
            msg="There should be a msg mentioning the file was 'created'. "
            "Current stdout:\n%r" % out)
        self.assertEqual(
            err, "",
            msg="No error message expected. "
            "Current stderr:\n%s" % err)
        self.assertTrue(
            os.path.exists('.gitchangelog.rc'),
            msg="File must have been created.")
Esempio n. 39
0
    def test_include_merge_options(self):
        """We must be able to define a small gitchangelog.rc that adjust only
        one variable of all the builtin defaults."""

        w("""cat <<EOF > .gitchangelog.rc

include_merge = False

EOF

            git checkout -b develop
            git commit -m "made on develop branch" --allow-empty
            git checkout master
            git merge develop --no-ff

        """)
        changelog = w('$tprog')
        self.assertNotContains(
            changelog,
            "Merge",
            msg="Should not contain commit with 'Merge' in it... "
            "content of changelog:\n%s" % changelog)
Esempio n. 40
0
    def test_reuse_options(self):
        """We must be able to define a small gitchangelog.rc that adjust only
        one variable of all the builtin defaults."""

        w("""cat <<EOF > .gitchangelog.rc

ignore_regexps += [r'XXX', ]

EOF
        """)
        changelog = w('$tprog')
        self.assertNotContains(
            changelog, "XXX",
            msg="Should not contain commit with XXX in it... "
            "content of changelog:\n%s" % changelog)
        self.assertContains(
            changelog, "dd file ``e``",
            msg="Should contain at least a message of other commits... "
            "content of changelog:\n%s" % changelog)
        self.assertNotContains(
            changelog, "!minor",
            msg="Shouldn't contain !minor tagged commit neither... "
            "content of changelog:\n%s" % changelog)
Esempio n. 41
0
    def test_provided_templates(self):
        """Run all provided templates at least once"""

        for label, directory in [("makotemplate", "mako"),
                                 ("mustache", "mustache")]:
            template_dir = os.path.join(
                os.path.dirname(os.path.realpath(__file__)),
                "..", "templates", directory)
            templates = glob.glob(os.path.join(template_dir, "*.tpl"))
            template_labels = [os.path.basename(f).split(".")[0]
                               for f in templates]
            for tpl in template_labels:
                w("""cat <<EOF > .gitchangelog.rc

output_engine = %s(%r)

EOF
                """ % (label, tpl))
                out, err, errlvl = cmd('$tprog')
                self.assertEqual(
                    errlvl, 0,
                    msg="Should not fail on %s(%r) " % (label, tpl) +
                    "Current stderr:\n%s" % indent(err))
Esempio n. 42
0
    def test_unexistent_template_name(self):
        """Reference implementation should match mustache and mako implem"""

        w("""cat <<EOF > .gitchangelog.rc

output_engine = mustache('doesnotexist')

EOF
        """)
        out, err, errlvl = cmd('$tprog')
        self.assertEqual(errlvl,
                         1,
                         msg="Should fail as template does not exist")
        self.assertEqual(
            out,
            "",
            msg="No stdout was expected since there was an error. "
            "Current stdout:\n%r" % out)
        self.assertContains(
            err,
            "doesnotexist",
            msg="There should be an error message mentioning 'doesnotexist'. "
            "Current stderr:\n%s" % err)
        self.assertContains(
            err,
            "restructuredtext",
            msg="The error message should mention 'available'. "
            "Current stderr:\n%s" % err)
        self.assertContains(err,
                            "mustache",
                            msg="The error message should mention 'mustache'. "
                            "Current stderr:\n%s" % err)
        self.assertContains(
            err,
            "restructuredtext",
            msg="The error message should mention 'restructuredtext'. "
            "Current stderr:\n%s" % err)
Esempio n. 43
0
    def test_git_flow_w_long_merge_text(self):
        """ Test the git flow option produces the correct message with either long or short merge text """

        ## Merges could show up as "Merge branch 'x' into y"
        ## or "Merge branch 'x'"

        w("""
            cat <<EOF > .gitchangelog.rc

include_merges = False
git_flow = True

EOF
            ## Instead of creating a real git history, I find it easier to fake the merges
            git commit -m 'Merge branch feature/big_feature into develop' --allow-empty
            git commit -m 'Merge branch fix/save_the_world' --allow-empty

        """)
        changelog = w('$tprog')

        ## The changelog should have properly formatted text for both
        self.assert_contains(changelog, "Completed big feature")
        self.assert_contains(changelog, "Fixed save the world")
        self.assert_not_contains(changelog, "into develop")
Esempio n. 44
0
    def test_git_flow_w_long_merge_text(self):
        """ Test the git flow option produces the correct message with either long or short merge text """

        ## Merges could show up as "Merge branch 'x' into y"
        ## or "Merge branch 'x'"

        w("""
            cat <<EOF > .gitchangelog.rc

include_merges = False
git_flow = True

EOF
            ## Instead of creating a real git history, I find it easier to fake the merges
            git commit -m 'Merge branch feature/big_feature into develop' --allow-empty
            git commit -m 'Merge branch fix/save_the_world' --allow-empty

        """)
        changelog = w('$tprog')

        ## The changelog should have properly formatted text for both
        self.assert_contains(changelog, "Completed big feature")
        self.assert_contains(changelog, "Fixed save the world")
        self.assert_not_contains(changelog, "into develop")
Esempio n. 45
0
    def test_hard_release_attribution(self):
        """ Test attribution for out-of-band releases, where chronologically older commits are not in the next tag """

        REFERENCE_CHANGELOG = r"""Changelog
=========

0.2 (2000-01-12)
----------------

New
~~~

- Something. [Alice]

- Commit on develop branch. [Alice]

Changes
~~~~~~~

- Continued development. [Alice]

Fix
~~~

- More work on develop branch. [Alice]

Other
~~~~~

- Merge tag '0.1.1' into test_hard_release_attribution. [The Committer]

0.1.1 (2000-01-11)
------------------

Fix
~~~

- Out-of-band hotfix. [Alice]

0.1 (2000-01-07)
----------------

Changes
~~~~~~~

- Modified ``b`` XXX. [Alice]

Fix
~~~

- Something. [Mary]

0.0.3 (2000-01-05)
------------------

New
~~~

- Add file ``e``, modified ``b`` [Bob]

- Add file ``c`` [Charly]

0.0.2 (2000-01-02)
------------------

New
~~~

- Add ``b`` with non-ascii chars éèà⧵. [Alice]


"""

        w("""

#            Target tree:
#
#            * 85b9161 (HEAD, tag: 0.2, test_hard_release_attribution) new: something
#            *   9979e78 Merge tag '0.1.1' into test_hard_release_attribution.
#            |\
#            | * 23fbe34 (tag: 0.1.1, master) fix: out-of-band hotfix
#            * | c47e172 fix: more work on develop branch
#            * | 02dd137 chg: continued development
#            * | 8491971 new: commit on develop branch
#            * | 8713012 (tag: 0.1) fix: something
#            |/   <--- From here down is base setup
#            * fc4d378 chg: modified ``b`` XXX
#            * a45944e (tag: 0.0.3) chg: modified ``b`` !minor
#            * d6a8ac7 new: add file ``e``, modified ``b``
#            * 1e6109b new: add file ``c``
#            * d7573c1 (tag: 0.0.2) new: add ``b`` with non-ascii chars éèà⧵
#            * b8fb18b (tag: 0.0.1) new: first commit
#

            ## Branch
            git checkout master
            git checkout -b test_hard_release_attribution

            ## Build the tree
            git commit -m 'fix: something' \
                --author 'Mary <*****@*****.**>' \
                --date '2000-01-07 11:00:00' \
                --allow-empty

            git tag 0.1

            git commit -m 'new: commit on develop branch' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-08 11:00:00' \
                --allow-empty

            git commit -m 'chg: continued development' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-09 11:00:00' \
                --allow-empty

            git commit -m 'fix: more work on develop branch' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-10 11:00:00' \
                --allow-empty

           git checkout 0.1

            git commit -m 'fix: out-of-band hotfix' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-11 11:00:00' \
                --allow-empty

            git tag 0.1.1

            git checkout test_hard_release_attribution
            git merge 0.1.1

            git commit -m 'new: something' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-12 11:00:00' \
                --allow-empty

            git tag 0.2

        """)
        ## Good debugging tool
        # print w("""
        #     gitk --all
        # """)
        changelog = w('$tprog')
        self.assertEqual(
            changelog, REFERENCE_CHANGELOG,
            msg="Should match our reference output... "
            "diff from what it should be:\n%s"
            % '\n'.join(difflib.unified_diff(REFERENCE_CHANGELOG.split("\n"),
                                             changelog.split("\n"),
                                             lineterm="",
                                             n=100)))
Esempio n. 46
0
    def test_easy_release_attribution(self):
        """ Test attribution when commits are already linear """

        REFERENCE_CHANGELOG = r"""Changelog
=========

0.0.5 (2000-01-11)
------------------

New
~~~

- Something. [Alice]

- Commit on develop branch. [Alice]

Changes
~~~~~~~

- Continued development. [Alice]

Fix
~~~

- More work on develop branch. [Alice]

0.0.4 (2000-01-07)
------------------

Changes
~~~~~~~

- Modified ``b`` XXX. [Alice]

Fix
~~~

- Something. [Alice]

0.0.3 (2000-01-05)
------------------

New
~~~

- Add file ``e``, modified ``b`` [Bob]

- Add file ``c`` [Charly]

0.0.2 (2000-01-02)
------------------

New
~~~

- Add ``b`` with non-ascii chars éèà⧵. [Alice]


"""

        w("""

#            Target tree:
#
#            * 6c0fd62 (tag: 0.0.5, develop) new: something
#            * 7d6286f fix: more work on develop branch
#            * 8c1e3d6 chg: continued development
#            * fa3d4bd new: commit on develop branch
#            * ec1a19c (tag: 0.0.4) fix: something


            ## Branch
            git checkout master
            git checkout -b test_easy_release_attribution

            ## Build the tree
            git commit -m 'fix: something' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-07 11:00:00' \
                --allow-empty

            git tag 0.0.4

            git commit -m 'new: commit on develop branch' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-08 11:00:00' \
                --allow-empty

            git commit -m 'chg: continued development' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-09 11:00:00' \
                --allow-empty

            git commit -m 'fix: more work on develop branch' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-10 11:00:00' \
                --allow-empty

            git commit -m 'new: something' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-11 11:00:00' \
                --allow-empty

            git tag 0.0.5

        """)
        changelog = w('$tprog')
        self.assertEqual(
            changelog,
            REFERENCE_CHANGELOG,
            msg="Should match our reference output... "
            "diff from what it should be:\n%s" % '\n'.join(
                difflib.unified_diff(REFERENCE_CHANGELOG.split("\n"),
                                     changelog.split("\n"),
                                     lineterm="")))
Esempio n. 47
0
    def test_hard_release_attribution(self):
        """ Test attribution for out-of-band releases, where chronologically older commits are not in the next tag """

        REFERENCE_CHANGELOG = r"""Changelog
=========

0.2 (2000-01-12)
----------------

New
~~~

- Something. [Alice]

- Commit on develop branch. [Alice]

Changes
~~~~~~~

- Continued development. [Alice]

Fix
~~~

- More work on develop branch. [Alice]

Other
~~~~~

- Merge tag '0.1.1' into test_hard_release_attribution. [The Committer]

0.1.1 (2000-01-11)
------------------

Fix
~~~

- Out-of-band hotfix. [Alice]

0.1 (2000-01-07)
----------------

Changes
~~~~~~~

- Modified ``b`` XXX. [Alice]

Fix
~~~

- Something. [Mary]

0.0.3 (2000-01-05)
------------------

New
~~~

- Add file ``e``, modified ``b`` [Bob]

- Add file ``c`` [Charly]

0.0.2 (2000-01-02)
------------------

New
~~~

- Add ``b`` with non-ascii chars éèà⧵. [Alice]


"""

        w("""

#            Target tree:
#
#            * 85b9161 (HEAD, tag: 0.2, test_hard_release_attribution) new: something
#            *   9979e78 Merge tag '0.1.1' into test_hard_release_attribution.
#            |\
#            | * 23fbe34 (tag: 0.1.1, master) fix: out-of-band hotfix
#            * | c47e172 fix: more work on develop branch
#            * | 02dd137 chg: continued development
#            * | 8491971 new: commit on develop branch
#            * | 8713012 (tag: 0.1) fix: something
#            |/   <--- From here down is base setup
#            * fc4d378 chg: modified ``b`` XXX
#            * a45944e (tag: 0.0.3) chg: modified ``b`` !minor
#            * d6a8ac7 new: add file ``e``, modified ``b``
#            * 1e6109b new: add file ``c``
#            * d7573c1 (tag: 0.0.2) new: add ``b`` with non-ascii chars éèà⧵
#            * b8fb18b (tag: 0.0.1) new: first commit
#

            ## Branch
            git checkout master
            git checkout -b test_hard_release_attribution

            ## Build the tree
            git commit -m 'fix: something' \
                --author 'Mary <*****@*****.**>' \
                --date '2000-01-07 11:00:00' \
                --allow-empty

            git tag 0.1

            git commit -m 'new: commit on develop branch' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-08 11:00:00' \
                --allow-empty

            git commit -m 'chg: continued development' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-09 11:00:00' \
                --allow-empty

            git commit -m 'fix: more work on develop branch' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-10 11:00:00' \
                --allow-empty

           git checkout 0.1

            git commit -m 'fix: out-of-band hotfix' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-11 11:00:00' \
                --allow-empty

            git tag 0.1.1

            git checkout test_hard_release_attribution
            git merge 0.1.1

            git commit -m 'new: something' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-12 11:00:00' \
                --allow-empty

            git tag 0.2

        """)
        ## Good debugging tool
        # print w("""
        #     gitk --all
        # """)
        changelog = w('$tprog')
        self.assertEqual(
            changelog,
            REFERENCE_CHANGELOG,
            msg="Should match our reference output... "
            "diff from what it should be:\n%s" % '\n'.join(
                difflib.unified_diff(REFERENCE_CHANGELOG.split("\n"),
                                     changelog.split("\n"),
                                     lineterm="",
                                     n=100)))
Esempio n. 48
0
    def setUp(self):
        super(GitChangelogTest, self).setUp()

        w(r"""

            ## Adding first file
            echo 'Hello' > a
            git add a
            git commit -m 'new: first commit' \
                --author 'Bob <*****@*****.**>' \
                --date '2000-01-01 10:00:00'
            git tag 0.0.1

            ## Adding second file
            echo 'Second file with strange non-ascii char: éèà⧵' > b
            git add b

            ## Notice there are no section here.
            git commit -m 'add ``b`` with non-ascii chars éèà⧵

Change-Id: Ic8aaa0728a43936cd4c6e1ed590e01ba8f0fbf5b' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-02 11:00:00'
            git tag 0.0.2

            ## Adding more files
            echo 'Third file' > c
            git add c
            git commit -m 'new: add file ``c``' \
                --author 'Charly <*****@*****.**>' \
                --date '2000-01-03 12:00:00'
            echo 'Fourth file' > d
            echo 'With a modification' >> b
            git add d b
            git commit -m 'new: add file ``e``, modified ``b``

This is a message body.

With multi-line content:
- one
- two

Bug: #42
Change-Id: Ic8aaa0728a43936cd4c6e1ed590e01ba8f0fbf5b
Signed-off-by: A. U. Thor <*****@*****.**>
CC: R. E. Viewer <*****@*****.**>
Subject: This is a fake subject spanning to several lines
  as you can see
' \
                --author 'Bob <*****@*****.**>' \
                --date '2000-01-04 13:00:00'

            echo 'minor addition 1' >> b
            git commit -am 'chg: modified ``b`` !minor' \
                --author 'Bob <*****@*****.**>' \
                --date '2000-01-05 13:00:00'
            git tag 0.0.3

            ## Add untagged commits
            echo 'addition' >> b
            git commit -am 'chg: modified ``b`` XXX' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-06 11:00:00'

            """)
Esempio n. 49
0
    def test_unreleased_version_nonstandard_tags(self):
        """ Test git version string works if tag format isn't semantic.

        Test if the option is on and the last commit is not tagged,
        and the tag format is not the standard semantic version, then it still works.

        eg. tags like 'sprint-x' with commits after the tag, should output
        'sprint-x-y', with y being the number of commits post tag. Previous code
        would mangle it into just 'sprint-x' """

        REFERENCE_CHANGELOG = r"""Changelog
=========

sprint-8-1.dev_r200001071900
----------------------------

Fix
~~~

- Something. [Alice]

sprint-8 (2000-01-06)
---------------------

Changes
~~~~~~~

- Modified ``b`` XXX. [Alice]

0.0.3 (2000-01-05)
------------------

New
~~~

- Add file ``e``, modified ``b`` [Bob]

- Add file ``c`` [Charly]

0.0.2 (2000-01-02)
------------------

New
~~~

- Add ``b`` with non-ascii chars éèà⧵. [Alice]


"""

        w("""

            cat <<EOF > .gitchangelog.rc

tag_filter_regexp = r'^sprint[\-\.\s\_]*\d+|[0-9]+(?:\.[0-9]+(\.[0-9]+)?)?$'
replace_unreleased_version_label = True

EOF
            ## Branch
            git checkout master

            git tag sprint-8

            git checkout -b test_default_case

            ## Build the tree
            git commit -m 'fix: something' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-07 11:00:00' \
                --allow-empty

        """)
        changelog = w('$tprog')
        self.assertEqual(
            changelog,
            REFERENCE_CHANGELOG,
            msg="Should match our reference output... "
            "diff from what it should be:\n%s" % '\n'.join(
                difflib.unified_diff(REFERENCE_CHANGELOG.split("\n"),
                                     changelog.split("\n"),
                                     lineterm="")))
Esempio n. 50
0
    def test_version_tagged(self):
        """ Test if the option is on and the last commit is tagged, then the log uses the tag """

        REFERENCE_CHANGELOG = r"""Changelog
=========

0.0.4 (2000-01-07)
------------------

Changes
~~~~~~~

- Modified ``b`` XXX. [Alice]

Fix
~~~

- Something. [Alice]

0.0.3 (2000-01-05)
------------------

New
~~~

- Add file ``e``, modified ``b`` [Bob]

- Add file ``c`` [Charly]

0.0.2 (2000-01-02)
------------------

New
~~~

- Add ``b`` with non-ascii chars éèà⧵. [Alice]


"""

        w("""

            cat <<EOF > .gitchangelog.rc

replace_unreleased_version_label = True

EOF
            ## Branch
            git checkout master
            git checkout -b test_default_case

            ## Build the tree
            git commit -m 'fix: something' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-07 11:00:00' \
                --allow-empty

            git tag 0.0.4

        """)
        changelog = w('$tprog')
        self.assertEqual(
            changelog,
            REFERENCE_CHANGELOG,
            msg="Should match our reference output... "
            "diff from what it should be:\n%s" % '\n'.join(
                difflib.unified_diff(REFERENCE_CHANGELOG.split("\n"),
                                     changelog.split("\n"),
                                     lineterm="")))
    def test_version_tagged(self):
        """ Test if the option is on and the last commit is tagged, then the log uses the tag """

        REFERENCE_CHANGELOG = r"""Changelog
=========

0.0.4 (2000-01-07)
------------------

Changes
~~~~~~~

- Modified ``b`` XXX. [Alice]

Fix
~~~

- Something. [Alice]

0.0.3 (2000-01-05)
------------------

New
~~~

- Add file ``e``, modified ``b`` [Bob]

- Add file ``c`` [Charly]

0.0.2 (2000-01-02)
------------------

New
~~~

- Add ``b`` with non-ascii chars éèà⧵. [Alice]


"""

        w("""

            cat <<EOF > .gitchangelog.rc

replace_unreleased_version_label = True

EOF
            ## Branch
            git checkout master
            git checkout -b test_default_case

            ## Build the tree
            git commit -m 'fix: something' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-07 11:00:00' \
                --allow-empty

            git tag 0.0.4

        """)
        changelog = w('$tprog')
        self.assertEqual(
            changelog, REFERENCE_CHANGELOG,
            msg="Should match our reference output... "
            "diff from what it should be:\n%s"
            % '\n'.join(difflib.unified_diff(REFERENCE_CHANGELOG.split("\n"),
                                             changelog.split("\n"),
                                             lineterm="")))
    def test_unreleased_version_nonstandard_tags(self):
        """ Test git version string works if tag format isn't semantic.

        Test if the option is on and the last commit is not tagged,
        and the tag format is not the standard semantic version, then it still works.

        eg. tags like 'sprint-x' with commits after the tag, should output
        'sprint-x-y', with y being the number of commits post tag. Previous code
        would mangle it into just 'sprint-x' """

        REFERENCE_CHANGELOG = r"""Changelog
=========

sprint-8-1.dev_r200001071900
----------------------------

Fix
~~~

- Something. [Alice]

sprint-8 (2000-01-06)
---------------------

Changes
~~~~~~~

- Modified ``b`` XXX. [Alice]

0.0.3 (2000-01-05)
------------------

New
~~~

- Add file ``e``, modified ``b`` [Bob]

- Add file ``c`` [Charly]

0.0.2 (2000-01-02)
------------------

New
~~~

- Add ``b`` with non-ascii chars éèà⧵. [Alice]


"""

        w("""

            cat <<EOF > .gitchangelog.rc

tag_filter_regexp = r'^sprint[\-\.\s\_]*\d+|[0-9]+(?:\.[0-9]+(\.[0-9]+)?)?$'
replace_unreleased_version_label = True

EOF
            ## Branch
            git checkout master

            git tag sprint-8

            git checkout -b test_default_case

            ## Build the tree
            git commit -m 'fix: something' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-07 11:00:00' \
                --allow-empty

        """)
        changelog = w('$tprog')
        self.assertEqual(
            changelog, REFERENCE_CHANGELOG,
            msg="Should match our reference output... "
            "diff from what it should be:\n%s"
            % '\n'.join(difflib.unified_diff(REFERENCE_CHANGELOG.split("\n"),
                                             changelog.split("\n"),
                                             lineterm="")))
Esempio n. 53
0
    def test_easy_release_attribution(self):
        """ Test attribution when commits are already linear """

        REFERENCE_CHANGELOG = r"""Changelog
=========

0.0.5 (2000-01-11)
------------------

New
~~~

- Something. [Alice]

- Commit on develop branch. [Alice]

Changes
~~~~~~~

- Continued development. [Alice]

Fix
~~~

- More work on develop branch. [Alice]

0.0.4 (2000-01-07)
------------------

Changes
~~~~~~~

- Modified ``b`` XXX. [Alice]

Fix
~~~

- Something. [Alice]

0.0.3 (2000-01-05)
------------------

New
~~~

- Add file ``e``, modified ``b`` [Bob]

- Add file ``c`` [Charly]

0.0.2 (2000-01-02)
------------------

New
~~~

- Add ``b`` with non-ascii chars éèà⧵. [Alice]


"""

        w("""

#            Target tree:
#
#            * 6c0fd62 (tag: 0.0.5, develop) new: something
#            * 7d6286f fix: more work on develop branch
#            * 8c1e3d6 chg: continued development
#            * fa3d4bd new: commit on develop branch
#            * ec1a19c (tag: 0.0.4) fix: something


            ## Branch
            git checkout master
            git checkout -b test_easy_release_attribution

            ## Build the tree
            git commit -m 'fix: something' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-07 11:00:00' \
                --allow-empty

            git tag 0.0.4

            git commit -m 'new: commit on develop branch' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-08 11:00:00' \
                --allow-empty

            git commit -m 'chg: continued development' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-09 11:00:00' \
                --allow-empty

            git commit -m 'fix: more work on develop branch' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-10 11:00:00' \
                --allow-empty

            git commit -m 'new: something' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-11 11:00:00' \
                --allow-empty

            git tag 0.0.5

        """)
        changelog = w('$tprog')
        self.assertEqual(
            changelog, REFERENCE_CHANGELOG,
            msg="Should match our reference output... "
            "diff from what it should be:\n%s"
            % '\n'.join(difflib.unified_diff(REFERENCE_CHANGELOG.split("\n"),
                                             changelog.split("\n"),
                                             lineterm="")))
Esempio n. 54
0
    def setUp(self):
        super(GitChangelogTest, self).setUp()

        w(r"""

            ## Adding first file
            echo 'Hello' > a
            git add a
            git commit -m 'new: first commit' \
                --author 'Bob <*****@*****.**>' \
                --date '2000-01-01 10:00:00'
            git tag 0.0.1

            ## Adding second file
            echo 'Second file with strange non-ascii char: éèà⧵' > b
            git add b

            ## Notice there are no section here.
            git commit -m 'add ``b`` with non-ascii chars éèà⧵

Change-Id: Ic8aaa0728a43936cd4c6e1ed590e01ba8f0fbf5b' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-02 11:00:00'
            git tag 0.0.2

            ## Adding more files
            echo 'Third file' > c
            git add c
            git commit -m 'new: add file ``c``' \
                --author 'Charly <*****@*****.**>' \
                --date '2000-01-03 12:00:00'
            echo 'Fourth file' > d
            echo 'With a modification' >> b
            git add d b
            git commit -m 'new: add file ``e``, modified ``b``

This is a message body.

With multi-line content:
- one
- two

Bug: #42
Change-Id: Ic8aaa0728a43936cd4c6e1ed590e01ba8f0fbf5b
Signed-off-by: A. U. Thor <*****@*****.**>
CC: R. E. Viewer <*****@*****.**>
Subject: This is a fake subject spanning to several lines
  as you can see
' \
                --author 'Bob <*****@*****.**>' \
                --date '2000-01-04 13:00:00'

            echo 'minor addition 1' >> b
            git commit -am 'chg: modified ``b`` !minor' \
                --author 'Bob <*****@*****.**>' \
                --date '2000-01-05 13:00:00'
            git tag 0.0.3

            ## Add untagged commits
            echo 'addition' >> b
            git commit -am 'chg: modified ``b`` XXX' \
                --author 'Alice <*****@*****.**>' \
                --date '2000-01-06 11:00:00'

            """)