Skip to content

Commit

Permalink
fast-forward
Browse files Browse the repository at this point in the history
  • Loading branch information
rmaffesoli committed Apr 26, 2024
2 parents 629b64b + 4a91e5d commit 28dee7b
Show file tree
Hide file tree
Showing 25 changed files with 810 additions and 248 deletions.
253 changes: 215 additions & 38 deletions LICENSE

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions kernel/create_branch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/usr/bin/env python

# p4templates - custom tooling to quickly create Helix Core depot/stream/group/permission setups.
# Copyright (C) 2024 Perforce Software, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

"""create_branch doc string"""

from __future__ import print_function
Expand Down
17 changes: 17 additions & 0 deletions kernel/create_depot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
#!/usr/bin/env python

# p4templates - custom tooling to quickly create Helix Core depot/stream/group/permission setups.
# Copyright (C) 2024 Perforce Software, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from __future__ import print_function


Expand Down
16 changes: 16 additions & 0 deletions kernel/create_group.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/usr/bin/env python

# p4templates - custom tooling to quickly create Helix Core depot/stream/group/permission setups.
# Copyright (C) 2024 Perforce Software, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

"""create_group doc string"""

from __future__ import print_function
Expand Down
16 changes: 16 additions & 0 deletions kernel/create_stream.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/usr/bin/env python

# p4templates - custom tooling to quickly create Helix Core depot/stream/group/permission setups.
# Copyright (C) 2024 Perforce Software, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

"""create_stream doc string"""

from __future__ import print_function
Expand Down
16 changes: 16 additions & 0 deletions kernel/create_user.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/usr/bin/env python

# p4templates - custom tooling to quickly create Helix Core depot/stream/group/permission setups.
# Copyright (C) 2024 Perforce Software, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

"""create_user doc string"""

from __future__ import print_function
Expand Down
16 changes: 16 additions & 0 deletions kernel/edit_permissions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/usr/bin/env python

# p4templates - custom tooling to quickly create Helix Core depot/stream/group/permission setups.
# Copyright (C) 2024 Perforce Software, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

"""edit_permissions doc string"""

from __future__ import print_function
Expand Down
16 changes: 16 additions & 0 deletions kernel/edit_typemap.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/usr/bin/env python

# p4templates - custom tooling to quickly create Helix Core depot/stream/group/permission setups.
# Copyright (C) 2024 Perforce Software, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

"""edit_permissions doc string"""

from __future__ import print_function
Expand Down
16 changes: 16 additions & 0 deletions kernel/process_template.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/usr/bin/env python

# p4templates - custom tooling to quickly create Helix Core depot/stream/group/permission setups.
# Copyright (C) 2024 Perforce Software, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

"""process_template doc string"""

from __future__ import print_function
Expand Down
17 changes: 16 additions & 1 deletion kernel/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# p4templates - custom tooling to quickly create Helix Core depot/stream/group/permission setups.
# Copyright (C) 2024 Perforce Software, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from __future__ import print_function

import json
Expand Down Expand Up @@ -129,4 +145,3 @@ def gather_existing_template_names(template_folder_path="./templates"):
template_lut[identifier] = os.path.join(dir_name, template_file)

return template_lut

45 changes: 33 additions & 12 deletions p4templates_tool.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
# p4templates - custom tooling to quickly create Helix Core depot/stream/group/permission setups.
# Copyright (C) 2024 Perforce Software, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import os
import sys
from argparse import ArgumentParser

from PyQt6.QtWidgets import QApplication
Expand All @@ -12,35 +29,39 @@ def main():
parser.add_argument("-t", "--template_dir", default="./templates")
parsed_args = parser.parse_args()

config_path = parsed_args.config
script_dir = os.path.dirname(__file__)
if getattr(sys, 'frozen', False):
os.chdir(os.path.dirname(sys.executable))
else:
os.chdir(script_dir)

config_path = parsed_args.config
config_path = os.path.abspath(config_path)

if not os.path.exists(config_path):
print('A valid server configuration file is required')
else:
config_path = os.path.abspath(config_path)



config = load_server_config(config_path)

if config.get('template_dir', ''):
template_dir = config.get('template_dir')
else:
template_dir = parsed_args.template_dir


template_dir = os.path.abspath(template_dir)
if not os.path.exists(template_dir):
print('Template directory not found')
else:
template_dir = os.path.abspath(template_dir)

script_dir = os.path.dirname(__file__)
os.chdir(script_dir)



app = QApplication([])
P4TemplateLoaderDialog(
config_path=config_path,
config_path=config_path,
template_dir=template_dir
)


if __name__ == "__main__":
main()

30 changes: 23 additions & 7 deletions tests/kernel/test_create_branch.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# p4templates - custom tooling to quickly create Helix Core depot/stream/group/permission setups.
# Copyright (C) 2024 Perforce Software, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import pytest

from p4templates.kernel.create_branch import create_branch, populate_branch, delete_branch
Expand All @@ -14,7 +30,7 @@ def __init__(self, ):
'Options': None,
'View': None
}

def fetch_branch(self, branch_name):
self.branch['Branch'] = branch_name
self.fetch_called = True
Expand All @@ -24,13 +40,13 @@ def save_branch(self, branch_spec):
self.branch = branch_spec
self.save_called = True
return self.branch

def delete_branch(self, branch_name):
self.delete_called=True

def run(self, *args):
self.run_args = args



@pytest.mark.parametrize(
Expand All @@ -44,18 +60,18 @@ def test_create_branch(name, owner, options, view, dryrun, fetch_called, save_ca
m_server = MockP4()

create_branch(m_server, name, owner, options, view, dryrun)

assert m_server.fetch_called == fetch_called
assert m_server.save_called == save_called
assert m_server.branch == expected_branch

def test_populate_branch():
m_server = MockP4()
populate_branch(m_server, 'test_branch')

populate_branch(m_server, 'test_branch')

assert m_server.run_args == ('populate', '-b', 'test_branch')

def test_delete_branch():
m_server = MockP4()

Expand Down
22 changes: 19 additions & 3 deletions tests/kernel/test_create_depot.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# p4templates - custom tooling to quickly create Helix Core depot/stream/group/permission setups.
# Copyright (C) 2024 Perforce Software, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import pytest

from p4templates.kernel.create_depot import create_depot
Expand All @@ -15,7 +31,7 @@ def __init__(self, ):

def iterate_depots(self):
return [self.depot]

def fetch_depot(self, depot_name):
self.depot['Depot'] = depot_name
self.depot['StreamDepth'] = '//{}/1'.format(depot_name)
Expand All @@ -26,7 +42,7 @@ def save_depot(self, depot_spec):
self.depot = depot_spec
self.save_called = 1
return self.depot


@pytest.mark.parametrize(
'name,type,depth,dryrun,fetch_called,save_called,expected_depot',
Expand All @@ -40,7 +56,7 @@ def test_create_depot(name, type, depth, dryrun, fetch_called, save_called, expe
m_server = MockP4()

create_depot(m_server, name, type, depth, dryrun)

assert m_server.depot == expected_depot
assert m_server.fetch_called == fetch_called
assert m_server.save_called == save_called
Loading

0 comments on commit 28dee7b

Please sign in to comment.