Skip to content

Commit

Permalink
Generate credentials-ext
Browse files Browse the repository at this point in the history
  • Loading branch information
Yang Cao committed Sep 12, 2023
1 parent 40bdc7d commit 99ad124
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 46 deletions.
97 changes: 53 additions & 44 deletions credentials.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,56 @@
## named "credentials-ext.properties" with the properties to overwrite.
##

#
# The JIRA_USER_NAME should be an email address.
#
# JIRA_USER_NAME=<jira_user_name>

#
# Get JIRA_TOKEN should be jira token.
#
# JIRA_TOKEN=<jira_token>

#
# The TESTRAY_USER_NAME should be an email address.
#
# TESTRAY_USER_NAME=<testray_user_name>

#
# The TESTRAY_PASSWORD should be testray password.
#
# TESTRAY_PASSWORD=<testray_password>

#
# The LOCAL_REPO_PATH should look like /path/to/repo.
#
# LOCAL_REPO_PATH=<path_to_repo>

#
# The TEAM_REPO_NAME should look like liferay-echo/liferay-portal.
#
# TEAM_REPO_NAME=<team_repo_name>

#
# The GITHUB_REVIEWER_NAME should look like david-gutierrez-mesa.
#
# GITHUB_REVIEWER_NAME=<reviewer>

#
# The GITHUB_USER_NAME should look like Tim-Cao.
#
# GITHUB_USER_NAME=<github_user_name>

#
# The GITHUB_TOKEN should be github token.
#
# GITHUB_TOKEN=<github_token>
#
# The JIRA_USER_NAME should be an email address.
#

JIRA_USER_NAME=

#
# Get JIRA_TOKEN should be jira token.
#

JIRA_TOKEN=

#
# The TESTRAY_USER_NAME should be an email address.
#

TESTRAY_USER_NAME=

#
# The TESTRAY_PASSWORD should be testray password.
#

TESTRAY_PASSWORD=

#
# The LOCAL_REPO_PATH should look like /path/to/liferay-portal.
#

LOCAL_REPO_PATH=

#
# The TEAM_REPO_NAME should look like liferay-echo/liferay-portal.
#

TEAM_REPO_NAME=

#
# The GITHUB_REVIEWER_NAME should look like david-gutierrez-mesa.
#

GITHUB_REVIEWER_NAME=

#
# The GITHUB_USER_NAME should look like Tim-Cao.
#

GITHUB_USER_NAME=

#
# The GITHUB_TOKEN should be github token.
#

GITHUB_TOKEN=
26 changes: 25 additions & 1 deletion liferay/util/credentials.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import subprocess

from jproperties import Properties

Expand All @@ -9,4 +10,27 @@ def get_credentials(key):
with open(os.path.join(os.path.dirname(__file__), '../../') + '/credentials-ext.properties', 'rb') as config_file:
configs.load(config_file)

return configs.get(key).data
return configs.get(key).data

def open_credentials():
root = os.path.join(os.path.dirname(__file__), "../../")

if os.path.exists(os.path.join(root, 'credentials-ext.properties')) == False:
print("Creating credentials-ext.properties...")

with open(os.path.join(root, 'credentials.properties'),'r') as credentials, open(
os.path.join(root, 'credentials-ext.properties'),'w') as credentials_ext:

credentials_content = credentials.readlines()

for line in range(7, len(credentials_content)):
credentials_ext.write(credentials_content[line])

print("credentials-ext.properties is created")
else:
print("Opening credentials-ext.properties...")

try:
subprocess.check_call(["code", "-rg", "credentials-ext.properties"])
except Exception as e:
print(str(e))
11 changes: 10 additions & 1 deletion script_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
from liferay.apps import (create_pr_and_forward, create_test_fix_ticket,
forward_failure_pull_request, write_comments,
write_description)
from liferay.util import credentials


class ScriptApp(App):
BINDINGS = [
Binding("ctrl+c", "quit", "Quit"),
Binding("shift+insert", "paste", "Paste"),
Binding("ctrl+u", "delete_left_all", "Delete all to the left")
Binding("ctrl+u", "delete_left_all", "Delete all to the left"),
Binding("ctrl+o", "open_credentials", "Open credentials-ext")
]

CSS_PATH = root + "/liferay/src/css/main.css"
Expand Down Expand Up @@ -110,6 +112,13 @@ def compose(self) -> ComposeResult:
yield Output(highlight=True, markup=True)
yield Footer()

@work(exclusive=True, thread=True)
def action_open_credentials(self) -> None:
self.query_one(RichLog).clear()
self.query_one(RichLog).begin_capture_print()

credentials.open_credentials()

@work(exclusive=True, thread=True)
def create_pr_and_forward(self) -> None:
local_branch_name= self.query_one("#local-branch").value
Expand Down

0 comments on commit 99ad124

Please sign in to comment.