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

snapshot: Include hostname in commit message #63

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions stbt_rig.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import re
import shutil
import signal
import socket
import subprocess
import sys
import tempfile
Expand Down Expand Up @@ -1660,9 +1661,12 @@ def take_snapshot(self):
else:
extra_env = {}

commit_message = "snapshot\n\nremoteref: %s\nhostname: %s" % (
remoteref, socket.gethostname())

commit_sha = self._git(
['commit-tree', write_tree, '-p', base_commit, '-m',
"snapshot\n\nremoteref: %s" % remoteref],
['commit-tree', write_tree, '-p', base_commit,
'-m', commit_message],
extra_env=extra_env).strip()

if no_workingdir_changes:
Expand Down
8 changes: 6 additions & 2 deletions test_stbt_rig.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ def test_testpack_snapshot_no_change_if_no_commits(test_pack):
commit_sha, run_sha = test_pack.take_snapshot()
assert rev_parse("HEAD") == run_sha
assert tree_sha(commit_sha) == tree_sha(run_sha)
assert commit_msg(commit_sha) == (
"snapshot\n\nremoteref: refs/heads/mybranch")
assert re.match(dedent("""\
snapshot

remoteref: refs/heads/mybranch
hostname: (drothlisxps13|fv-|Mac-)"""),
commit_msg(commit_sha))

# Check that the SHA is deterministic:
time.sleep(1)
Expand Down
Loading