Fixed and Added.

This commit is contained in:
Saturneic 2019-03-12 02:28:36 +08:00
parent 6d8d5d8c8a
commit dd32ae7661
6 changed files with 397 additions and 201 deletions

2
.idea/giteasy.iml generated
View File

@ -4,7 +4,7 @@
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" /> <excludeFolder url="file://$MODULE_DIR$/venv" />
</content> </content>
<orderEntry type="jdk" jdkName="Python 3.7 (giteasy)" jdkType="Python SDK" /> <orderEntry type="jdk" jdkName="Python 3.7" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
<component name="TestRunnerService"> <component name="TestRunnerService">

2
.idea/misc.xml generated
View File

@ -3,5 +3,5 @@
<component name="JavaScriptSettings"> <component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" /> <option name="languageLevel" value="ES6" />
</component> </component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (giteasy)" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7" project-jdk-type="Python SDK" />
</project> </project>

154
.idea/workspace.xml generated
View File

@ -2,10 +2,12 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="d703f139-38f3-455d-a086-a2da561870b5" name="Default Changelist" comment=""> <list default="true" id="d703f139-38f3-455d-a086-a2da561870b5" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/window.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/giteasy.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/giteasy.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/git.py" beforeDir="false" afterPath="$PROJECT_DIR$/git.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/git.py" beforeDir="false" afterPath="$PROJECT_DIR$/git.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/keygen.py" beforeDir="false" afterPath="$PROJECT_DIR$/keygen.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/keygen.py" beforeDir="false" afterPath="$PROJECT_DIR$/keygen.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/window.py" beforeDir="false" afterPath="$PROJECT_DIR$/window.py" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -14,10 +16,10 @@
<option name="LAST_RESOLUTION" value="IGNORE" /> <option name="LAST_RESOLUTION" value="IGNORE" />
</component> </component>
<component name="CoverageDataManager"> <component name="CoverageDataManager">
<SUITE FILE_PATH="coverage/giteasy$Debug.coverage" NAME="Debug Coverage Results" MODIFIED="1552305147101" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/giteasy$ssh.coverage" NAME="ssh Coverage Results" MODIFIED="1552191792390" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" /> <SUITE FILE_PATH="coverage/giteasy$ssh.coverage" NAME="ssh Coverage Results" MODIFIED="1552191792390" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/giteasy$window.coverage" NAME="window Coverage Results" MODIFIED="1552301739669" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" /> <SUITE FILE_PATH="coverage/giteasy$window.coverage" NAME="window Coverage Results" MODIFIED="1552328718602" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/giteasy$keygen.coverage" NAME="keygen Coverage Results" MODIFIED="1552276631897" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" /> <SUITE FILE_PATH="coverage/giteasy$keygen.coverage" NAME="keygen Coverage Results" MODIFIED="1552305621065" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/giteasy$Debug.coverage" NAME="Debug Coverage Results" MODIFIED="1552275762807" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component> </component>
<component name="DatabaseView"> <component name="DatabaseView">
<option name="SHOW_INTERMEDIATE" value="true" /> <option name="SHOW_INTERMEDIATE" value="true" />
@ -33,15 +35,46 @@
<expand /> <expand />
<select /> <select />
</component> </component>
<component name="FUSProjectUsageTrigger">
<session id="46200952">
<usages-collector id="statistics.lifecycle.project">
<counts>
<entry key="project.open.time.0" value="1" />
<entry key="project.opened" value="1" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.edit">
<counts>
<entry key="py" value="2309" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.edit">
<counts>
<entry key="Python" value="2309" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.open">
<counts>
<entry key="py" value="1" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.open">
<counts>
<entry key="Python" value="1" />
</counts>
</usages-collector>
</session>
</component>
<component name="FileEditorManager"> <component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="true"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/git.py"> <entry file="file://$PROJECT_DIR$/git.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="354"> <state relative-caret-position="286">
<caret line="165" column="14" lean-forward="true" selection-start-line="165" selection-start-column="14" selection-end-line="165" selection-end-column="14" /> <caret line="201" column="23" selection-start-line="201" selection-start-column="23" selection-end-line="201" selection-end-column="23" />
<folding> <folding>
<element signature="e#1#10#0" expanded="true" /> <element signature="e#0#9#0" expanded="true" />
<marker date="1552328892578" expanded="true" signature="3619:3810" ph="..." />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -50,8 +83,8 @@
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/ssh.py"> <entry file="file://$PROJECT_DIR$/ssh.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="150"> <state relative-caret-position="117">
<caret line="6" column="18" selection-start-line="6" selection-start-column="18" selection-end-line="6" selection-end-column="18" /> <caret line="25" selection-start-line="25" selection-end-line="25" />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -59,25 +92,20 @@
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/keygen.py"> <entry file="file://$PROJECT_DIR$/keygen.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="325"> <state relative-caret-position="196">
<caret line="13" column="64" lean-forward="true" selection-start-line="13" selection-start-column="64" selection-end-line="13" selection-end-column="64" /> <caret line="17" column="82" lean-forward="true" selection-start-line="17" selection-start-column="82" selection-end-line="17" selection-end-column="82" />
<folding>
<element signature="e#0#13#0" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/window.py"> <entry file="file://$PROJECT_DIR$/window.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="654"> <state relative-caret-position="230">
<caret line="158" lean-forward="true" selection-start-line="158" selection-end-line="158" /> <caret line="186" column="91" lean-forward="true" selection-start-line="186" selection-start-column="91" selection-end-line="186" selection-end-column="91" />
<folding> <folding>
<element signature="e#0#21#0" expanded="true" /> <element signature="e#0#21#0" expanded="true" />
<element signature="e#92#237#0" /> <marker date="1552328641660" expanded="true" signature="9150:9296" ph="..." />
<element signature="e#1052#1235#0" />
<element signature="e#1318#1405#0" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -114,16 +142,23 @@
</list> </list>
</option> </option>
</component> </component>
<component name="ProjectFrameBounds" extendedState="6"> <component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
<option name="y" value="30" /> <component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
<sorting>DEFINITION_ORDER</sorting>
</component>
<component name="ProjectFrameBounds">
<option name="y" value="23" />
<option name="width" value="1440" /> <option name="width" value="1440" />
<option name="height" value="804" /> <option name="height" value="811" />
</component> </component>
<component name="ProjectView"> <component name="ProjectView">
<navigator proportions="" version="1"> <navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" /> <foldersAlwaysOnTop value="true" />
</navigator> </navigator>
<panes> <panes>
<pane id="Scope" />
<pane id="ProjectPane"> <pane id="ProjectPane">
<subPane> <subPane>
<expand> <expand>
@ -131,6 +166,11 @@
<item name="giteasy" type="b2602c69:ProjectViewProjectNode" /> <item name="giteasy" type="b2602c69:ProjectViewProjectNode" />
<item name="giteasy" type="462c0819:PsiDirectoryNode" /> <item name="giteasy" type="462c0819:PsiDirectoryNode" />
</path> </path>
<path>
<item name="giteasy" type="b2602c69:ProjectViewProjectNode" />
<item name="giteasy" type="462c0819:PsiDirectoryNode" />
<item name="bin" type="462c0819:PsiDirectoryNode" />
</path>
<path> <path>
<item name="giteasy" type="b2602c69:ProjectViewProjectNode" /> <item name="giteasy" type="b2602c69:ProjectViewProjectNode" />
<item name="External Libraries" type="cb654da1:ExternalLibrariesNode" /> <item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
@ -139,7 +179,6 @@
<select /> <select />
</subPane> </subPane>
</pane> </pane>
<pane id="Scope" />
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
@ -176,13 +215,13 @@
<envs> <envs>
<env name="PYTHONUNBUFFERED" value="1" /> <env name="PYTHONUNBUFFERED" value="1" />
</envs> </envs>
<option name="SDK_HOME" value="C:\Users\Saturneric\PycharmProjects\giteasy\venv\Scripts\python.exe" /> <option name="SDK_HOME" value="/usr/local/bin/python3.7" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" /> <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="false" /> <option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="C:\Users\Saturneric\PycharmProjects\giteasy\git.py" /> <option name="SCRIPT_NAME" value="C:$PROJECT_DIR$/../../../Saturneric/PycharmProjects/giteasy/git.py" />
<option name="PARAMETERS" value="" /> <option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" /> <option name="EMULATE_TERMINAL" value="false" />
@ -213,7 +252,7 @@
<option name="INPUT_FILE" value="" /> <option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="keygen" type="PythonConfigurationType" factoryName="Python" temporary="true"> <configuration name="keygen" type="PythonConfigurationType" factoryName="Python">
<module name="giteasy" /> <module name="giteasy" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
@ -265,7 +304,6 @@
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Python.window" /> <item itemvalue="Python.window" />
<item itemvalue="Python.keygen" />
</list> </list>
</recent_temporary> </recent_temporary>
</component> </component>
@ -295,21 +333,21 @@
<option name="totallyTimeSpent" value="21133000" /> <option name="totallyTimeSpent" value="21133000" />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1056" extended-state="6" /> <frame x="0" y="23" width="1440" height="811" extended-state="6" />
<editor active="true" /> <editor active="true" />
<layout> <layout>
<window_info id="Favorites" order="0" side_tool="true" /> <window_info id="Favorites" order="0" side_tool="true" />
<window_info content_ui="combo" id="Project" order="1" visible="true" weight="0.14285715" /> <window_info content_ui="combo" id="Project" order="1" visible="true" weight="0.14449213" />
<window_info id="Structure" order="2" side_tool="true" weight="0.25" /> <window_info id="Structure" order="2" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Database Changes" order="0" show_stripe_button="false" /> <window_info anchor="bottom" id="Database Changes" order="0" show_stripe_button="false" />
<window_info anchor="bottom" id="Terminal" order="1" /> <window_info anchor="bottom" id="Terminal" order="1" sideWeight="0.49928468" weight="0.32962447" />
<window_info anchor="bottom" id="Event Log" order="2" sideWeight="0.5010661" side_tool="true" weight="0.2635575" /> <window_info anchor="bottom" id="Event Log" order="2" sideWeight="0.50214595" side_tool="true" visible="true" weight="0.2628651" />
<window_info anchor="bottom" id="Version Control" order="3" /> <window_info anchor="bottom" id="Version Control" order="3" sideWeight="0.4985694" weight="0.32962447" />
<window_info anchor="bottom" id="Python Console" order="4" weight="0.3286517" /> <window_info anchor="bottom" id="Python Console" order="4" weight="0.3286517" />
<window_info anchor="bottom" id="Docker" order="5" show_stripe_button="false" /> <window_info anchor="bottom" id="Docker" order="5" show_stripe_button="false" />
<window_info anchor="bottom" id="Message" order="6" /> <window_info anchor="bottom" id="Message" order="6" />
<window_info anchor="bottom" id="Find" order="7" weight="0.329718" /> <window_info anchor="bottom" id="Find" order="7" weight="0.329718" />
<window_info active="true" anchor="bottom" id="Run" order="8" sideWeight="0.4989339" visible="true" weight="0.2635575" /> <window_info active="true" anchor="bottom" id="Run" order="8" sideWeight="0.49785408" visible="true" weight="0.2628651" />
<window_info anchor="bottom" id="Debug" order="9" weight="0.30758426" /> <window_info anchor="bottom" id="Debug" order="9" weight="0.30758426" />
<window_info anchor="bottom" id="Cvs" order="10" weight="0.25" /> <window_info anchor="bottom" id="Cvs" order="10" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="11" weight="0.4" /> <window_info anchor="bottom" id="Inspection" order="11" weight="0.4" />
@ -324,6 +362,9 @@
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" /> <option name="version" value="1" />
</component> </component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value="Fixed and Added." /> <MESSAGE value="Fixed and Added." />
<option name="LAST_COMMIT_MESSAGE" value="Fixed and Added." /> <option name="LAST_COMMIT_MESSAGE" value="Fixed and Added." />
@ -340,42 +381,45 @@
</breakpoint-manager> </breakpoint-manager>
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file:///usr/local/lib/python3.7/site-packages/paramiko/ecdsakey.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="260" column="54" lean-forward="true" selection-start-line="260" selection-start-column="54" selection-end-line="260" selection-end-column="54" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/keygen.py"> <entry file="file://$PROJECT_DIR$/keygen.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="325"> <state relative-caret-position="196">
<caret line="13" column="64" lean-forward="true" selection-start-line="13" selection-start-column="64" selection-end-line="13" selection-end-column="64" /> <caret line="17" column="82" lean-forward="true" selection-start-line="17" selection-start-column="82" selection-end-line="17" selection-end-column="82" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/git.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="286">
<caret line="201" column="23" selection-start-line="201" selection-start-column="23" selection-end-line="201" selection-end-column="23" />
<folding> <folding>
<element signature="e#0#13#0" expanded="true" /> <element signature="e#0#9#0" expanded="true" />
<marker date="1552328892578" expanded="true" signature="3619:3810" ph="..." />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/ssh.py"> <entry file="file://$PROJECT_DIR$/ssh.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="150"> <state relative-caret-position="117">
<caret line="6" column="18" selection-start-line="6" selection-start-column="18" selection-end-line="6" selection-end-column="18" /> <caret line="25" selection-start-line="25" selection-end-line="25" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/window.py"> <entry file="file://$PROJECT_DIR$/window.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="654"> <state relative-caret-position="230">
<caret line="158" lean-forward="true" selection-start-line="158" selection-end-line="158" /> <caret line="186" column="91" lean-forward="true" selection-start-line="186" selection-start-column="91" selection-end-line="186" selection-end-column="91" />
<folding> <folding>
<element signature="e#0#21#0" expanded="true" /> <element signature="e#0#21#0" expanded="true" />
<element signature="e#92#237#0" /> <marker date="1552328641660" expanded="true" signature="9150:9296" ph="..." />
<element signature="e#1052#1235#0" />
<element signature="e#1318#1405#0" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/git.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="354">
<caret line="165" column="14" lean-forward="true" selection-start-line="165" selection-start-column="14" selection-end-line="165" selection-end-column="14" />
<folding>
<element signature="e#1#10#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>

170
git.py
View File

@ -7,11 +7,23 @@ class Git(ssh.SSH):
projects = {} projects = {}
projects_list = [] projects_list = []
remotes = {} remotes = {}
if_set_local = False
if_global_init = False
if_global_init_local = False
if_base_init = False
if_fix_project = False
if_fix_local = False
if_get_branches = False
if_get_remote = False
if_fetch_remote = False
if_get_project = False
if_connected = False
def __init__(self, hostname, path, user, passwd): def __init__(self, hostname, path, user, passwd):
super().__init__(hostname, path, user, passwd) super().__init__(hostname, path, user, passwd)
self.base_path = [False] self.base_path = [False]
self.connect(5) self.connect(5)
self.if_connected = True
self.local_path = None self.local_path = None
self.fix_cmd = None self.fix_cmd = None
self.fix_name = None self.fix_name = None
@ -25,16 +37,18 @@ class Git(ssh.SSH):
cmd += "git config --global user.name \"{0}\";".format(git_user) cmd += "git config --global user.name \"{0}\";".format(git_user)
stdout, stderr = self.run(cmd) stdout, stderr = self.run(cmd)
if self.check_error(stderr): if self.check_error(stderr):
print("Global setting successful.") print("Global Setting Successful.")
self.if_global_init = True
else: else:
print(stderr) print(stderr)
raise ValueError("Args Abnormal") raise ValueError("Args Error")
def base_init(self): def base_init(self):
if self.if_connected:
stdout, stderr = self.run("ls {}".format(self.path)) stdout, stderr = self.run("ls {}".format(self.path))
if self.check_error(stderr): if self.check_error(stderr):
if "giteasy\n" in stdout: if "giteasy\n" in stdout:
print("Directory already found.") print("Directory Already Found.")
else: else:
stdout, stderr = self.run("mkdir {0}/{1}".format(self.path, "giteasy")) stdout, stderr = self.run("mkdir {0}/{1}".format(self.path, "giteasy"))
if self.check_error(stderr): if self.check_error(stderr):
@ -42,20 +56,23 @@ class Git(ssh.SSH):
else: else:
raise ValueError(stderr) raise ValueError(stderr)
self.base_path = [True, "{0}{1}".format(self.path, "giteasy")] self.base_path = [True, "{0}{1}".format(self.path, "giteasy")]
self.if_base_init = True
else: else:
raise ValueError("Home Path Abnormal") raise ValueError("Path Error")
else:
raise AttributeError("Connect First.")
def create_project(self, name): def create_project(self, name):
if self.base_path[0]: if self.if_base_init:
stdout, stderr = self.run("mkdir {0}/{1}".format(self.base_path[1], name)) if os.path.exists("{0}/{1}.git".format(self.base_path[1], name)):
print("Server Project Already Exist.")
else:
stdout, stderr = self.run("mkdir {0}/{1}.git".format(self.base_path[1], name))
if self.check_error(stderr): if self.check_error(stderr):
print("Succeed In Making Directory.") print("Succeed In Making Directory.")
self.projects[name] = {"path": "{0}/{1}".format(self.base_path[1], name), "branch": []} self.projects[name] = {"path": "{0}/{1}".format(self.base_path[1], name), "branch": []}
cmd = "cd {0};".format(self.projects[name]["path"]) cmd = "cd {0}.git;".format(self.projects[name]["path"])
cmd += "git init;" cmd += "git init --bare;"
cmd += "touch ReadME.md;"
cmd += "git add *;"
cmd += "git commit --message=init;"
stdout, stderr = self.run(cmd) stdout, stderr = self.run(cmd)
if self.check_error(stderr): if self.check_error(stderr):
print("Succeed In Getting Repository.") print("Succeed In Getting Repository.")
@ -63,31 +80,50 @@ class Git(ssh.SSH):
print(stderr) print(stderr)
raise ValueError("Target Path Abnormal") raise ValueError("Target Path Abnormal")
else: else:
raise ValueError("Base Path Abnormal") raise ValueError("Path Error.")
else: else:
raise UnboundLocalError("Init Base First") raise AttributeError("Set Base Path First.")
def clone_project(self): def clone_project(self):
if self.if_set_local and self.if_connected:
os.chdir(self.local_path) os.chdir(self.local_path)
os.popen("git clone ssh://{0}@{1}:{2}/{3}/.git".format(self.user, self.hostname, self.base_path[1], os.popen("git clone ssh://{0}@{1}:{2}/{3}".format(self.user, self.hostname, self.base_path[1],
self.fix_name)) self.fix_name))
else:
raise AttributeError("Connect & Set Local First.")
def fix_project_local(self):
if self.if_set_local and self.if_fix_project:
os.chdir(os.path.join(self.local_path, self.fix_name))
self.if_fix_local = True
else:
raise AttributeError("Set Local & Fix Project First.")
def init_project_local(self, name): def init_project_local(self, name):
if self.if_set_local:
os.chdir(self.local_path) os.chdir(self.local_path)
try: try:
os.mkdir(name) os.mkdir(name)
except FileExistsError: except FileExistsError:
os.chdir(os.path.join(self.local_path, name)) os.chdir(os.path.join(self.local_path, name))
raise FileExistsError("Project Already Exist.") print("Local Project Already Exist.")
os.chdir(os.path.join(self.local_path, name)) os.chdir(os.path.join(self.local_path, name))
cmd = "git init" cmd = "git init"
readme = open(os.path.join(self.local_path, name,"ReadME.md"),"w")
readme.write("#Default Project Introduction.#\n")
readme.close()
cmd += "git add *"
cmd += "git commit --message=\"Initial Commit\""
os.popen(cmd) os.popen(cmd)
else:
raise AttributeError("Set Local First.")
def global_init_local(self): def global_init_local(self):
cmd = "git config --global user.email \"{0}\"".format(self.git_email) cmd = "git config --global user.email \"{0}\"".format(self.git_email)
print(os.popen(cmd).read()) print(os.popen(cmd).read())
cmd = "git config --global user.name \"{0}\"".format(self.git_user) cmd = "git config --global user.name \"{0}\"".format(self.git_user)
print(os.popen(cmd).read()) print(os.popen(cmd).read())
self.if_global_init = True
def update_projects(self): def update_projects(self):
if self.base_path[0]: if self.base_path[0]:
@ -95,10 +131,10 @@ class Git(ssh.SSH):
if self.check_error(stderr): if self.check_error(stderr):
reform = re.compile("\w+") reform = re.compile("\w+")
for project in stdout: for project in stdout:
print("PROJECT", project)
project_name = reform.match(project).string.strip('\n') project_name = reform.match(project).string.strip('\n')
self.projects[project_name] = {"path": "{0}/{1}".format(self.base_path[1], project_name), self.projects[project_name] = {"path": "{0}/{1}".format(self.base_path[1], project_name),
"branch": []} "branch": []}
self.if_get_project = True
else: else:
raise ValueError("Base Path Abnormal") raise ValueError("Base Path Abnormal")
@ -108,98 +144,124 @@ class Git(ssh.SSH):
raise UnboundLocalError("Init Base First") raise UnboundLocalError("Init Base First")
def list_projects(self): def list_projects(self):
if self.if_get_project:
for project in self.projects.keys(): for project in self.projects.keys():
self.projects_list.append(project) self.projects_list.append(project)
print(project) else:
raise AttributeError("Get Project First.")
def set_local(self, path): def set_local(self, path):
if self.if_connected:
self.remotes = {} self.remotes = {}
self.local_path = path self.local_path = path
self.if_set_local = True
os.chdir(self.local_path) os.chdir(self.local_path)
else:
raise AttributeError("Connect First.")
def add_remote(self, name="origin"): def add_remote(self, name="origin"):
os.popen("git remote add {3} ssh://{0}@{1}:{2}/{4}/.git".format(self.user, self.hostname, self.base_path[1], if self.if_base_init and self.if_get_project and self.if_fix_project:
name, self.fix_name)) stdout = os.popen("git remote add {3} ssh://{0}@{1}:{2}/{4}.git".format(self.user, self.hostname,
self.base_path[1],
name, self.fix_name)).read()
self.remotes[name] = {"name": name, self.remotes[name] = {"name": name,
"url": "ssh://{0}@{1}:{2}/{3}/.git".format(self.user, self.hostname, self.base_path[1], "url": "ssh://{0}@{1}:{2}/{3}.git".format(self.user, self.hostname, self.base_path[1],
self.fix_name)} self.fix_name)}
self.if_get_remote = True
return stdout
else:
raise AttributeError("Get Project & Base Init & Fix Project First.")
def fetch_remote(self, name): def fetch_remote(self, name):
if self.if_fix_project and self.if_base_init and self.if_set_local:
if name in self.remotes.keys(): if name in self.remotes.keys():
os.popen("git fetch {0}".format(name)) os.popen("git fetch {0}".format(name))
self.if_fetch_remote = True
else:
raise AttributeError("Set Local & Fix Project & Base Init First.")
def get_remote(self): def get_remote(self):
if self.if_fix_project and self.if_base_init and self.if_set_local:
ret_code = re.compile(r"[\t, ]") ret_code = re.compile(r"[\t, ]")
for remote in os.popen("git remote -v").readlines(): for remote in os.popen("git remote -v").readlines():
results = ret_code.split(remote) results = ret_code.split(remote)
print(results)
results = list(results) results = list(results)
if len(results) > 1: if len(results) >= 1:
self.remotes = {}
for item in results: for item in results:
if item[0] not in self.remotes.keys(): if item[0] not in self.remotes.keys():
self.remotes[results[0]] = {"name": results[0], "url": results[1]} self.remotes[results[0]] = {"name": results[0], "url": results[1]}
self.if_get_remote = True
else:
raise AttributeError("Set Local & Fix Project & Base Init First.")
def push_remote(self, name, branch): def push_remote(self, name, branch):
print(self.projects[self.fix_name]["branch"]) if self.if_fix_project and self.if_base_init and self.if_set_local \
print(self.projects[self.fix_name]) and self.if_get_remote:
if branch in self.projects[self.fix_name]["branch"] and name in self.remotes.keys(): if name in self.remotes.keys():
os.popen("git push {0} {1}".format(name, branch)) return os.popen("git push {0} {1}".format(name, branch)).read()
else: else:
raise ValueError("Branch or Name Abnormal") raise ValueError("Name Abnormal")
else:
raise AttributeError("Set Local & Fix Project & Base Init & Get Remote First.")
def pull_remote(self, name, branch): def pull_remote(self, name, branch):
if self.if_fix_project and self.if_base_init and self.if_set_local \
and self.if_get_remote:
if name in self.remotes.keys(): if name in self.remotes.keys():
os.popen("git pull {0} {1}".format(name, branch)) return os.popen("git pull {0} {1}".format(name, branch)).read()
else: else:
raise ValueError("Remote Error") raise ValueError("Remote Error")
else:
raise AttributeError("Set Local & Fix Project & Base Init & Get Remote & Get Branches First.")
def fix_project(self, name): def fix_project(self, name):
if name in self.projects_list: if self.if_get_project and self.if_base_init:
if name+".git" in self.projects_list:
self.fix_name = name self.fix_name = name
stdout, stderr = self.run("cd {0}".format(self.projects[name]["path"])) stdout, stderr = self.run("cd {0}".format(self.projects[name+".git"]["path"]))
if self.check_error(stderr): if self.check_error(stderr):
self.fix_cmd = "cd {0}".format(self.projects[name]["path"]) + ";" self.fix_cmd = "cd {0}".format(self.projects[name+".git"]["path"]) + ";"
os.chdir(os.path.join(self.local_path, self.fix_name)) self.if_fix_project = True
else: else:
raise ValueError("Project Path Abnormal") raise ValueError("Project Path Abnormal")
def commit(self, message):
if self.base_path[0]:
stdout, stderr = self.run(self.fix_cmd + "git commit --message={0}".format(message))
if self.check_error(stderr):
print(stdout)
else: else:
raise ValueError(stderr) raise AttributeError("Get Project & Base Init First.")
else:
raise UnboundLocalError("Init Base First")
def commit_local(self, message): def commit_local(self, message):
if self.if_set_local and self.if_fix_local and self.if_base_init:
if self.base_path[0]: if self.base_path[0]:
os.popen("git commit --message={0}".format(message)) stdout = os.popen("git commit --message={0}".format(message)).read()
return stdout
else: else:
raise UnboundLocalError("Init Base First") raise UnboundLocalError("Init Base First")
else:
raise AttributeError("Set Local & Fix Local & Base Init First.")
@staticmethod def add(self):
def add(): if self.if_set_local and self.if_fix_local and self.if_base_init:
os.popen("git add *") stdout = os.popen("git add *")
return stdout
else:
raise AttributeError("Set Local & Fix Local & Base Init First.")
def get_branch(self): def get_branch(self):
if self.base_path[0] and self.fix_name is not None: if self.if_get_project and self.if_base_init and self.if_fix_local:
stdout, stderr = self.run(self.fix_cmd + "git branch") stdout = os.popen("git branch").read()
if self.check_error(stderr): self.projects[self.fix_name+".git"]["branch"] = []
self.projects[self.fix_name]["branch"] = []
reform = re.compile("\w+") reform = re.compile("\w+")
for branch in stdout: for branch in stdout:
branch_name = reform.search("*master").group().strip('\n') branch_name = reform.search("*master").group().strip('\n')
self.projects[self.fix_name]["branch"].append(branch_name) self.projects[self.fix_name+".git"]["branch"].append(branch_name)
if '*' in str(branch): if '*' in str(branch):
self.projects[self.fix_name]["active_branch"] = branch_name self.projects[self.fix_name+".git"]["active_branch"] = branch_name
self.if_get_branches = True
else: else:
print(stderr) raise AttributeError("Get Project & Base Init & Fix Local First.")
raise ValueError("Command Error")
def list_branch(self): def list_branch(self):
if self.if_get_branches:
for project in self.projects.items(): for project in self.projects.items():
for branch in project[1]["branch"]: for branch in project[1]["branch"]:
if branch == project[1]["active_branch"]: if branch == project[1]["active_branch"]:

View File

@ -10,7 +10,7 @@ class Key(ssh.SSH):
self.connect(5) self.connect(5)
self.pub_key = None self.pub_key = None
self.keygen = None self.keygen = None
self.local_path = "C:\\Users\\Saturneric\\" self.local_path = "/Users/huyibing/"
self.public_key_path = self.local_path+".ssh/id_rsa.pub" self.public_key_path = self.local_path+".ssh/id_rsa.pub"
self.public_key = None self.public_key = None

120
window.py
View File

@ -1,5 +1,7 @@
from tkinter import * from tkinter import *
from tkinter.messagebox import *
import git import git
import os
class Window(Frame): class Window(Frame):
@ -70,6 +72,7 @@ class Main(Window):
self.push = Button(self) self.push = Button(self)
self.add = Button(self) self.add = Button(self)
self.commit = Button(self) self.commit = Button(self)
self.fix_local = Button(self)
self.info = None self.info = None
self.git = None self.git = None
@ -85,27 +88,32 @@ class Main(Window):
self.connection_status["fg"] = "red" self.connection_status["fg"] = "red"
self.connection_status["text"] = "Succeed" self.connection_status["text"] = "Succeed"
self.connection_status["fg"] = "green" self.connection_status["fg"] = "green"
try:
self.git.base_init() self.git.base_init()
self.git.update_projects() self.git.update_projects()
self.broad.insert(INSERT, "--------------------------\n") self.broad.insert(INSERT, "--------------------------\n")
self.broad.insert(INSERT, "SSH Connection [Succeed]\n") self.broad.insert(INSERT, "SSH Connection [Succeed]\n")
self.broad.insert(INSERT, self.hostname.get()+"\n") self.broad.insert(INSERT, self.hostname.get()+"\n")
self.broad.insert(INSERT, self.user_name.get()+"\n") self.broad.insert(INSERT, self.user_name.get()+"\n")
except AttributeError as errinfo:
showinfo(message=errinfo)
return
def do_list(self): def do_list(self):
try:
self.git.list_projects() self.git.list_projects()
except AttributeError as errinfo:
showinfo(message=errinfo)
return
self.broad.insert(INSERT, "--------------------------\n") self.broad.insert(INSERT, "--------------------------\n")
self.broad.insert(INSERT, "Projects: \n") self.broad.insert(INSERT, "Projects: \n")
for project in self.git.projects.items(): for project in self.git.projects.items():
print(project)
self.broad.insert(INSERT, "(*) "+project[0]+"\n") self.broad.insert(INSERT, "(*) "+project[0]+"\n")
def new_project(self): def new_project(self):
self.info = Info(Tk()) self.info = Info(Tk())
self.info.information_label["text"] = "Project Name: " self.info.information_label["text"] = "Project Name: "
self.info.set_click(self.new_project_callback) self.info.set_click(self.new_project_callback)
self.list_projects()
def do_fix_project(self): def do_fix_project(self):
self.info = Info(Tk()) self.info = Info(Tk())
@ -115,25 +123,50 @@ class Main(Window):
def new_project_callback(self): def new_project_callback(self):
if self.info is not None: if self.info is not None:
self.git.create_project(self.info.information.get()) self.git.create_project(self.info.information.get())
self.git.update_projects()
self.info.master.destroy() self.info.master.destroy()
self.info = None self.info = None
def do_fix_project_callback(self): def do_fix_project_callback(self):
if self.info is not None: if self.info is not None:
try:
self.broad.insert(INSERT, "--------------------------\n")
self.broad.insert(INSERT, "Fixing Project {0} \n".format(self.info.information.get()))
self.git.fix_project(self.info.information.get()) self.git.fix_project(self.info.information.get())
except AttributeError as errinfo:
showinfo(message=errinfo)
return
self.fix_project_label["text"] = "Fixed Project: {0}".format(self.info.information.get()) self.fix_project_label["text"] = "Fixed Project: {0}".format(self.info.information.get())
try:
self.git.get_remote()
self.broad.insert(INSERT, "Get Remote...OK \n")
if os.path.exists(os.path.join(self.git.local_path, self.git.fix_name)):
self.broad.insert(INSERT, "Check Local Project...OK \n")
else:
self.do_clone_project()
self.broad.insert(INSERT, "Set Local Project...OK \n")
self.do_fix_project_local()
self.broad.insert(INSERT, "Fix Local Project...OK \n")
self.git.get_branch()
self.broad.insert(INSERT, "Get Local Project's Branches...OK \n")
self.git.get_remote()
self.broad.insert(INSERT, "Set Local Project's Remote...OK \n")
except AttributeError as errinfo:
showinfo(message=errinfo)
return
self.info.master.destroy() self.info.master.destroy()
self.info = None self.info = None
self.do_get_branch()
self.do_clone_project()
self.do_add_remote()
self.do_list_remote()
def do_get_branch(self): def do_get_branch(self):
try:
self.git.get_branch() self.git.get_branch()
except AttributeError as errinfo:
showinfo(message=errinfo)
return
self.broad.insert(INSERT, "--------------------------\n") self.broad.insert(INSERT, "--------------------------\n")
self.broad.insert(INSERT, "Branches: \n") self.broad.insert(INSERT, "Branches: \n")
for branch in self.git.projects[self.git.fix_name]["branch"]: for branch in self.git.projects[self.git.fix_name+".git"]["branch"]:
print(branch) print(branch)
self.broad.insert(INSERT, "(*) " + branch + "\n") self.broad.insert(INSERT, "(*) " + branch + "\n")
@ -145,20 +178,41 @@ class Main(Window):
def do_set_local_callback(self): def do_set_local_callback(self):
if self.info is not None: if self.info is not None:
try:
if os.path.exists(self.info.information.get()):
self.git.set_local(self.info.information.get()) self.git.set_local(self.info.information.get())
self.broad.insert(INSERT, "--------------------------\n")
self.broad.insert(INSERT, "Set Local Path: {0}\n".format(self.info.information.get()))
else:
showinfo(message="{0} not exists.".format(self.info.information.get()))
return
except AttributeError as errinfo:
showinfo(message=errinfo)
return
except FileNotFoundError as errinfo:
showinfo(message=errinfo)
return
self.local_path_label["text"] = "Local Path: {0}".format(self.info.information.get()) self.local_path_label["text"] = "Local Path: {0}".format(self.info.information.get())
self.info.master.destroy() self.info.master.destroy()
self.info = None self.info = None
def do_clone_project(self): def do_clone_project(self):
self.git.clone_project() self.git.init_project_local(self.git.fix_name)
self.git.add_remote() # self.git.add_remote()
def do_add_remote(self): def do_add_remote(self):
try:
self.git.add_remote("origin") self.git.add_remote("origin")
except AttributeError as errinfo:
showinfo(errinfo)
return
def do_list_remote(self): def do_list_remote(self):
try:
self.git.get_remote() self.git.get_remote()
except AttributeError as errinfo:
showinfo(errinfo)
return
self.broad.insert(INSERT, "--------------------------\n") self.broad.insert(INSERT, "--------------------------\n")
self.broad.insert(INSERT, "Remotes: \n") self.broad.insert(INSERT, "Remotes: \n")
for remote in self.git.remotes.items(): for remote in self.git.remotes.items():
@ -166,13 +220,39 @@ class Main(Window):
self.broad.insert(INSERT, "(*) " + remote[1]["name"] + " " + remote[1]["url"] + "\n") self.broad.insert(INSERT, "(*) " + remote[1]["name"] + " " + remote[1]["url"] + "\n")
def do_pull(self): def do_pull(self):
self.git.pull_remote("origin", "master") try:
stdout = self.git.pull_remote("origin", "master")
self.broad.insert(INSERT, "--------------------------\n")
self.broad.insert(INSERT, "{0}\n".format(stdout))
except AttributeError as errinfo:
showinfo(message=errinfo)
return
def do_push(self): def do_push(self):
self.git.push_remote("origin", "master") try:
stdout = self.git.push_remote("origin", "master")
self.broad.insert(INSERT, "--------------------------\n")
self.broad.insert(INSERT, "{0}\n".format(stdout))
except AttributeError as errinfo:
showinfo(message=errinfo)
return
def do_add(self): def do_add(self):
self.git.add() try:
stdout=self.git.add()
self.broad.insert(INSERT, "--------------------------\n")
self.broad.insert(INSERT, "{0}\n".format(stdout))
except AttributeError as errinfo:
showinfo(message=errinfo)
return
def do_fix_project_local(self):
try:
self.git.fix_project_local()
except AttributeError as errinfo:
showinfo(message=errinfo)
return
def do_commit(self): def do_commit(self):
self.info = Info(Tk()) self.info = Info(Tk())
@ -181,7 +261,13 @@ class Main(Window):
self.info.set_click(self.do_commit_callback) self.info.set_click(self.do_commit_callback)
def do_commit_callback(self): def do_commit_callback(self):
self.git.commit_local(self.info.information.get()) try:
stdout=self.git.commit_local(self.info.information.get())
self.broad.insert(INSERT, "--------------------------\n")
self.broad.insert(INSERT, "{0}\n".format(stdout))
except AttributeError as errinfo:
showinfo(message=errinfo)
return
self.info.master.destroy() self.info.master.destroy()
self.info = None self.info = None
@ -257,13 +343,17 @@ class Main(Window):
self.commit["command"] = self.do_commit self.commit["command"] = self.do_commit
self.commit.grid(row=6, column=1) self.commit.grid(row=6, column=1)
self.fix_local["text"] = "Fix Local"
self.fix_local["command"] = self.do_fix_project_local
self.fix_local.grid(row=7, column=0)
self.broad.grid(row=1, column=2, columnspan=7, rowspan=6) self.broad.grid(row=1, column=2, columnspan=7, rowspan=6)
if __name__ == "__main__": if __name__ == "__main__":
root = Tk() root = Tk()
main = Main(root) main = Main(root)
main.set_width(900) main.set_width(1150)
main.apply() main.apply()
main.mainloop() main.mainloop()