apply-pr 3.2.0__tar.gz → 3.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: apply_pr
3
- Version: 3.2.0
3
+ Version: 3.2.2
4
4
  Summary: Apply Pull Requests from GitHub
5
5
  Home-page: https://github.com/gisce/apply_pr
6
6
  Author: GISCE-TI, S.L.
@@ -46,8 +46,25 @@ for k in output.keys():
46
46
  output[k] = False
47
47
 
48
48
 
49
+ def is_github_token_valid(token):
50
+ headers = {'Authorization': 'token {token}'.format(token=token)}
51
+ url = "https://api.github.com/user"
52
+
53
+ r = requests.get(url, headers=headers)
54
+
55
+ return r.status_code == 200
56
+
57
+
49
58
  def github_config(**config):
50
- return config_from_environment('GITHUB', ['token'], **config)
59
+ def validate(_config):
60
+ if 'token' not in _config or not _config['token']:
61
+ raise EnvironmentError("GITHUB_TOKEN variable not provided")
62
+ if not is_github_token_valid(_config['token']):
63
+ raise EnvironmentError("GITHUB_TOKEN not valid or expired")
64
+
65
+ res = config_from_environment('GITHUB', ['token'], **config)
66
+ validate(res)
67
+ return res
51
68
 
52
69
 
53
70
  def apply_pr_config(**config):
@@ -920,7 +937,7 @@ def prs_status(
920
937
  pr_number = pull_info['pullRequest']['number']
921
938
  try:
922
939
  pull = pull_info['pullRequest']
923
- projects_info = pull_info['projectItems']
940
+ projects_info = pull_info.get('projectItems', None)
924
941
  projects_show = ''
925
942
  to_apply = '{}'.format(str(pr_number))
926
943
  projects = ''
@@ -984,7 +1001,7 @@ def prs_status(
984
1001
  for prmsg in PRS[milestone]:
985
1002
  print('\t{}'.format(prmsg))
986
1003
  for prmsg in ERRORS:
987
- print('ERR\t{}'.format(prmsg))
1004
+ print('ERR\t{}'.format(prmsg))
988
1005
  if version:
989
1006
  print(colors.magenta('\nIncluded in projects\n'))
990
1007
  for x in IN_PROJECTS:
@@ -993,9 +1010,15 @@ def prs_status(
993
1010
  for _pr_project in TO_APPLY_CAUSE_PROJECT_VERSION_ERROR:
994
1011
  print(colors.red('* {}'.format(_pr_project)))
995
1012
  if CLOSED_PRS:
996
- print(colors.red('\nClosed PRS: "{}"\n'.format(
1013
+ print(colors.red('\n############# Closed PRS: "{}"\n'.format(
997
1014
  ' '.join(CLOSED_PRS)
998
1015
  )))
1016
+ if ERRORS:
1017
+ print(colors.yellow('\n⚠ ️WARNING ⚠ ️! ERRORS IN PRS. MUST BE REVIEW\n'))
1018
+ print(colors.yellow('##########################################\n'))
1019
+ for prmsg in ERRORS:
1020
+ print('ERR\t{}'.format(prmsg))
1021
+ print(colors.yellow('############# END ERROR PRS ###############\n'))
999
1022
  print(colors.yellow(
1000
1023
  '\nNot Included: "{}"\n'.format(' '.join(TO_APPLY))
1001
1024
  ))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: apply-pr
3
- Version: 3.2.0
3
+ Version: 3.2.2
4
4
  Summary: Apply Pull Requests from GitHub
5
5
  Home-page: https://github.com/gisce/apply_pr
6
6
  Author: GISCE-TI, S.L.
@@ -5,7 +5,7 @@ with open('requirements.txt', 'r') as f:
5
5
 
6
6
  setup(
7
7
  name='apply_pr',
8
- version='3.2.0',
8
+ version='3.2.2',
9
9
  packages=find_packages(),
10
10
  url='https://github.com/gisce/apply_pr',
11
11
  license='MIT',
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes