Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCM commit message #4877

Merged
merged 6 commits into from Apr 29, 2019

Conversation

Projects
None yet
3 participants
@uilianries
Copy link
Member

commented Mar 29, 2019

Retrieve last commit message (Git and SVN). We can use this feature in CPT (Conan Package Tools).

@tags: svn, slow, git

Changelog: Feature: Get commit message
Docs: conan-io/docs#1175

  • Refer to the issue that supports this Pull Request.
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

Note: By default this PR will skip the slower tests and will use a limited set of python versions. Check here how to increase the testing level by writing some tags in the current PR body text.

SCM commit message
- Retrieve last commit message (Git and SVN)

Signed-off-by: Uilian Ries <uilianries@gmail.com>

@ghost ghost assigned uilianries Mar 29, 2019

@ghost ghost added the stage: review label Mar 29, 2019

@uilianries uilianries referenced this pull request Mar 29, 2019

Merged

Get commit message #1175

@uilianries

This comment has been minimized.

Copy link
Member Author

commented Apr 1, 2019

I can't reproduce the error from Jenkins. 🤔

The error is:

======================================================================
ERROR: git_commit_message_test (disabled_revisions.conans.test.unittests.util.tools_test.GitToolTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/source/086f/py27/disabled_revisions/conans/test/unittests/util/tools_test.py", line 1606, in git_commit_message_test
    self.assertIsNone(git.get_commit_message())
  File "/tmp/source/086f/py27/disabled_revisions/conans/client/tools/scm.py", line 189, in get_commit_message
    "Unable to get git commit message from '%s': %s" % (self.folder, str(error)))
ConanException: Unable to get git commit message from '/tmp/tmpcSkUdzconans/path with spaces': Command 'git log -1 --format=%s%n%b' returned non-zero exit status 128

The command used to test:

nosetests conans.test -A "not rest_api" --verbosity=1 --processes=3 --process-timeout=1000 --process-restartworker --with-coverage 

Any idea how to create an environment which I can reproduce the same error?

@jgsogo

This comment has been minimized.

Copy link
Member

commented Apr 8, 2019

I cannot reproduce it in my machine, but having a look at the code this is my diagnosis:

When the test is calling to git.get_commit_message(), there are no commits in the repo, so according to the implementation these lines should be executed:

            status = self.run("status")
            if "No commits yet" in status:
                return None

Nevertheless, it is failing with Command 'git log -1 --format=%s%n%b', so the previous if-clause is False and the function is not returning, next line gets executed:

message = self.run("log -1 --format=%s%n%b")

and it fails (return non-zero).

⇒  git log -1 --format=%s%n%b
fatal: your current branch 'dev' does not have any commits yet

Btw, I'm not sure if we can rely on the No commits yet message (is it localized?), but maybe we can simplify the implementation to something like this:

    def get_commit_message(self):
        self.check_repo()
        try:
            return self.run("log -1 --format=%s%n%b")
        except Exception as error:
            return None

Or do you think that the command could fail for other reasons other than No commits yet?

@uilianries

This comment has been minimized.

Copy link
Member Author

commented Apr 10, 2019

@jgsogo thanks for helping! 😄

Or do you think that the command could fail for other reasons other than No commits yet?

No, I just wanted to avoid an ugly error message when trying to retrieve the log when there is no commit there. I'll update this PR to ignore the status step.

Ignore git log error
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Show resolved Hide resolved conans/test/unittests/util/tools_test.py Outdated
Show resolved Hide resolved conans/test/unittests/util/tools_test.py Outdated

jgsogo and others added some commits Apr 10, 2019

Retrieve SVN subrepo commit message
Co-Authored-By: uilianries <uilianries@gmail.com>
Commit message must be exactly as expected
Co-Authored-By: uilianries <uilianries@gmail.com>
Show resolved Hide resolved conans/client/tools/scm.py
@jgsogo

jgsogo approved these changes Apr 12, 2019

@lasote lasote added this to the 1.15 milestone Apr 12, 2019

@lasote lasote assigned jgsogo and unassigned uilianries Apr 26, 2019

@jgsogo

This comment has been minimized.

Copy link
Member

commented Apr 26, 2019

please, @uilianries , solve the conflicting files.

@ghost ghost assigned uilianries Apr 26, 2019

@lasote

This comment has been minimized.

Copy link
Contributor

commented Apr 29, 2019

@uilianries Test failing, looks like a missing import.

#4877 Move git and svn tests
- SCM tests were moved to a new place, so both message tests need
  to be reallocated to there.
@uilianries

This comment has been minimized.

Copy link
Member Author

commented Apr 29, 2019

@lasote It's working again! 😄

@lasote lasote merged commit 27d3860 into conan-io:develop Apr 29, 2019

2 checks passed

continuous-integration/jenkins/pr-head This commit looks good
Details
license/cla Contributor License Agreement is signed.
Details

@ghost ghost removed the stage: review label Apr 29, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.