Merge ~andersson123/lpci:tim_lpci into lpci:main

Proposed by Tim Andersson
Status: Needs review
Proposed branch: ~andersson123/lpci:tim_lpci
Merge into: lpci:main
Diff against target: 59 lines (+34/-0)
1 file modified
lpci/commands/run.py (+34/-0)
Reviewer Review Type Date Requested Status
Launchpad code reviewers Pending
Review via email: mp+443568@code.launchpad.net

Commit message

Add branch and url info to log

Description of the change

Add branch and url info to log

I find when I have a number of launchpad MP's going, I get bombarded with emails for each one detailing build logs. It's hard to distinguish just from the log which MP it is related to. So I think it'd be appropriate to tell the user the branch the job is running for prior to running. Then one can just ctrl+f branch to double check which MP or branch the job is pertaining to

To post a comment you must log in.
~andersson123/lpci:tim_lpci updated
53596d9... by Tim Andersson

reintroduce launchpad.yaml

a8a3e0d... by Tim Andersson

try different approach

43000ea... by Tim Andersson

further progress

ca27950... by Tim Andersson

why did my build fail :(

737ce43... by Tim Andersson

debugging

fbaac61... by Tim Andersson

Got it to work, now need to fix test suite

747810a... by Tim Andersson

modify main

12fe5fc... by Tim Andersson

okay, making progress

2cf2f36... by Tim Andersson

add also for run one

37d6176... by Tim Andersson

Add unit test

bdbd0b0... by Tim Andersson

amend linting errors

56fc91d... by Tim Andersson

progress ?

73683e7... by Tim Andersson

update

6fffcd1... by Tim Andersson

update script with new approach

03099ba... by Tim Andersson

fix whoopsie

ad34430... by Tim Andersson

remove from run-once

cc0bca9... by Tim Andersson

restore functionality and unit tests

0dba5bd... by Tim Andersson

fix ci (hopefully)

ab00446... by Tim Andersson

fix silly trailing newline

fdf10da... by Tim Andersson

dummy commit for test

529a81d... by Tim Andersson

try different approach

312d15f... by Tim Andersson

add to run-once

bfc719e... by Tim Andersson

alternative approach finished

77d62d4... by Tim Andersson

Get rid of messing with newlines

01446c9... by Tim Andersson

one final newline

Unmerged commits

01446c9... by Tim Andersson

one final newline

Failed
[FAILED] test:0 (build)
[WAITING] build:0 (build)
12 of 2 results
77d62d4... by Tim Andersson

Get rid of messing with newlines

Failed
[FAILED] test:0 (build)
[WAITING] build:0 (build)
12 of 2 results
bfc719e... by Tim Andersson

alternative approach finished

Failed
[FAILED] test:0 (build)
[WAITING] build:0 (build)
12 of 2 results
312d15f... by Tim Andersson

add to run-once

Failed
[FAILED] test:0 (build)
[WAITING] build:0 (build)
12 of 2 results
529a81d... by Tim Andersson

try different approach

Failed
[FAILED] test:0 (build)
[WAITING] build:0 (build)
12 of 2 results
fdf10da... by Tim Andersson

dummy commit for test

Failed
[FAILED] test:0 (build)
[WAITING] build:0 (build)
12 of 2 results
ab00446... by Tim Andersson

fix silly trailing newline

Succeeded
[SUCCEEDED] test:0 (build)
[SUCCEEDED] build:0 (build)
12 of 2 results
0dba5bd... by Tim Andersson

fix ci (hopefully)

Succeeded
[SUCCEEDED] test:0 (build)
[SUCCEEDED] build:0 (build)
12 of 2 results
cc0bca9... by Tim Andersson

restore functionality and unit tests

ad34430... by Tim Andersson

remove from run-once

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lpci/commands/run.py b/lpci/commands/run.py
2index c543ed1..e8cc7d4 100644
3--- a/lpci/commands/run.py
4+++ b/lpci/commands/run.py
5@@ -58,6 +58,36 @@ def _check_relative_path(path: PurePath, container: PurePath) -> PurePath:
6 raise CommandError(str(e), retcode=1)
7
8
9+def _highlighted_emit(message):
10+ highlight = "======================================================="
11+ emit.message(f"{highlight}\n{message.rstrip()}\n{highlight}")
12+
13+
14+def _get_git_info():
15+ git_message = ""
16+ branch = ""
17+ with open(".git/COMMIT_EDITMSG", 'r', encoding='utf-8') as cem_file:
18+ cem_msg = cem_file.read().splitlines()
19+ commit_info = ""
20+ for line in cem_msg:
21+ if line[0] != '#':
22+ commit_info += line
23+ elif "On branch" in line:
24+ git_message += "Branch: \n"
25+ branch = line.replace("# On branch ", "")
26+ git_message += branch + "\n"
27+ git_message += "Commit message:\n" + commit_info + "\n"
28+ with open(".git/refs/heads/" + branch, 'r', encoding='utf-8') as cid_file:
29+ git_message += "Commit id:\n" + cid_file.read()
30+ with open(".git/config", 'r', encoding='utf-8') as cfg_file:
31+ remote_url = cfg_file.read()
32+ remote_url = remote_url[remote_url.find("@")+1:]
33+ remote_url = remote_url[:remote_url.find("\n")]
34+ remote_url = "https://" + remote_url
35+ git_message += "remote:\n" + remote_url
36+ return "GIT INFO: \n\n" + git_message
37+
38+
39 def _convert_config_list_to_dict(list_: List[str]) -> Dict[str, str]:
40 # takes a list of strings, each string separated by an equal sign,
41 # and converts it to a dictionary
42@@ -718,6 +748,8 @@ class RunCommand(BaseCommand):
43 )
44 config = Config.load(args.config)
45
46+ _highlighted_emit(_get_git_info())
47+
48 provider = get_provider()
49 provider.ensure_provider_is_available()
50
51@@ -883,6 +915,8 @@ class RunOneCommand(BaseCommand):
52 )
53 config = Config.load(args.config)
54
55+ _highlighted_emit(_get_git_info())
56+
57 jobs = config.jobs.get(args.job, [])
58 if not jobs:
59 raise CommandError(f"No job definition for {args.job!r}")

Subscribers

People subscribed via source and target branches