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
Merged

SCM commit message #4877

merged 6 commits into from Apr 29, 2019

Conversation

@uilianries
Copy link
Member

@uilianries uilianries 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.

- Retrieve last commit message (Git and SVN)

Signed-off-by: Uilian Ries <uilianries@gmail.com>
@uilianries
Copy link
Member Author

@uilianries uilianries 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
Copy link
Member

@jgsogo jgsogo 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
Copy link
Member Author

@uilianries uilianries 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.

Signed-off-by: Uilian Ries <uilianries@gmail.com>
conans/test/unittests/util/tools_test.py Outdated Show resolved Hide resolved
conans/test/unittests/util/tools_test.py Outdated Show resolved Hide resolved
jgsogo and others added 2 commits Apr 10, 2019
Co-Authored-By: uilianries <uilianries@gmail.com>
Co-Authored-By: uilianries <uilianries@gmail.com>
conans/client/tools/scm.py Show resolved Hide resolved
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
Copy link
Member

@jgsogo jgsogo commented Apr 26, 2019

please, @uilianries , solve the conflicting files.

@ghost ghost assigned uilianries Apr 26, 2019
@lasote
Copy link
Contributor

@lasote lasote commented Apr 29, 2019

@uilianries Test failing, looks like a missing import.

- SCM tests were moved to a new place, so both message tests need
  to be reallocated to there.
@uilianries
Copy link
Member Author

@uilianries uilianries commented Apr 29, 2019

@lasote It's working again! 😄

@lasote lasote merged commit 27d3860 into conan-io:develop Apr 29, 2019
2 checks passed
@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
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants