GitScriptProject¶
- class GitScriptProject.GitScriptProject¶
Bases:
object
- property project_handle: int¶
- Gets the current project handle.
- property git_config_user_name: str¶
- Gets the user name from the git configuration.Makes use of the “user.name” setting.
- property git_config_user_email: str¶
- Gets the user email from the git configuration.Makes use of the “user.email” setting.
- property git_config_init_default_branch: str¶
- Gets the default branch name.Makes use of the “init.defaultBranch” setting.
- set_output_verbosity()¶
- Overwrites the current log level of the IGitReporter.
- reset_output_verbosity()¶
- Resets the log level of the <see cref=”IGitReporter”/> to its initial value
- init(gitProjectStoragePath: str) None ¶
- Add the given project to Git version control.NO INITIAL COMMIT!git-init - Create an empty Git repository or reinitialize an existing one
- Parameters:
gitProjectStoragePath (str) – Directory of the local git repository
- de_init(cleanUpFileSystem: bool = False) None ¶
- Removes the Git connection from the project and optionally deletes the working tree directory.
- Parameters:
cleanUpFileSystem (bool) – Flag for deleting the working tree directory
- status() ScriptGitStatusEntryCollection ¶
- Retrieves the current status for the working tree.git-status - Show the working tree status
- log(extendedObject: Optional[ScriptObject] = None) ScriptGitCommitCollection ¶
- Lookup and enumerate commits in the repository.git-log - Show commit logs
- Parameters:
extendedObject (ScriptObject) – ScriptObject to get the log from
- add_all() None ¶
- Adds all unstaged changes to the index.git-add –all - Add file contents to the index, all files in the entire working tree are concerned
- commit(sCommitMessage: str, sUserName: str, sUserEmail: str, bAllowEmptyCommits: bool = False, bAmendCommit: bool = False) ScriptGitCommit ¶
- Commits all staged changes (the index) to the repository.git-commit - Record changes to the repository
- Parameters:
sCommitMessage (str) – Commit message
sUserName (str) – Username
sUserEmail (str) – E-mail
bAllowEmptyCommits (bool) – Flag for creating a commit without any changes
bAmendCommit (bool) – Flag for amending the last commit
- commit_complete(sCommitMessage: str, sUserName: str, sUserEmail: str, bAllowEmptyCommits: bool = False, bAmendCommit: bool = False) ScriptGitCommit ¶
- Adds all unstaged changes to the index and then commits the index to the repository.git add –all + git commitgit-add - Add file contents to the indexgit-commit - Record changes to the repository
- Parameters:
sCommitMessage (str) – Commit message
sUserName (str) – Username
sUserEmail (str) – E-mail
bAllowEmptyCommits (bool) – Flag for creating a commit without any changes
bAmendCommit (bool) – Flag for amending the last commit
- branch() ScriptGitBranchCollection ¶
- Retreives information on currently existing branches.git-branch –vv - List branches
- branch_show_current() ScriptGitBranch ¶
- Gets the current branch.git branch –show-current
- branch_copy(oldBranchName: str, newBranchName: str, force: bool = False, checkout: bool = False, update_flags: VersionUpdateFlags = VersionUpdateFlags.NoUpdates) tuple[ScriptProject.ScriptProject, ScriptGitBranch.ScriptGitBranch] ¶
- branch_copy(oldScriptGitBranch: ScriptGitBranch, newBranchName: str, force: bool = False, checkout: bool = False, update_flags: VersionUpdateFlags = VersionUpdateFlags.NoUpdates) tuple[ScriptProject.ScriptProject, ScriptGitBranch.ScriptGitBranch]
- branch_copy(newBranchName: str, force: bool = False, checkout: bool = False, update_flags: VersionUpdateFlags = VersionUpdateFlags.NoUpdates) tuple[ScriptProject.ScriptProject, ScriptGitBranch.ScriptGitBranch]
- branch_copy(scriptGitCommit: ScriptGitCommit, newBranchName: str, force: bool = False, checkout: bool = False, update_flags: VersionUpdateFlags = VersionUpdateFlags.NoUpdates) tuple[ScriptProject.ScriptProject, ScriptGitBranch.ScriptGitBranch]
- Create a new branch from an existing branch name or commit SHA1.git branch (-c | -C) [<oldbranch>] <newbranch> - Copy a branch and the corresponding reflog.
- Parameters:
oldBranchName (str) – Name of the branch or commit to copy
oldScriptGitBranch (ScriptGitBranch) – Branch object of the branch to copy
scriptGitCommit (ScriptGitCommit) – Commit object of the commit to copy
newBranchName (str) – Name of the new branch that will be created
force (bool) – Flag to force copy
checkout (bool) – Flag to checkout the created branch
update_flags (VersionUpdateFlags) – Flags for handling project updates. Only effective, if checkout is True
- branch_delete(branchName: str, force: bool = False) None ¶
- branch_delete(scriptGitBranch: ScriptGitBranch, force: bool = False) None
- Delete the branch with the given namegit-branch (-d | -D) <branchname> - delete branches
- Parameters:
branchName (str) – Name of the branch to delete
scriptGitBranch (ScriptGitBranch) – Branch object of the branch to delete
force (bool) – Flag to force deletion
- checkout(branchName: str, force: bool = False, update_flags: VersionUpdateFlags = VersionUpdateFlags.NoUpdates) tuple[ScriptProject.ScriptProject, ScriptGitBranch.ScriptGitBranch] ¶
- checkout(scriptGitBranch: ScriptGitBranch, force: bool = False, update_flags: VersionUpdateFlags = VersionUpdateFlags.NoUpdates) tuple[ScriptProject.ScriptProject, ScriptGitBranch.ScriptGitBranch]
- checkout(scriptGitCommit: ScriptGitCommit, force: bool = False, update_flags: VersionUpdateFlags = VersionUpdateFlags.NoUpdates) tuple[ScriptProject.ScriptProject, ScriptGitBranch.ScriptGitBranch]
- Checkout branch with the given name.git-checkout [-f | –force] <branch> - Switch branchesThe project gets resynchronized to match the working tree.
- Parameters:
branchName (str) – Name of the branch or commit to checkout
scriptGitBranch (ScriptGitBranch) – Branch object of the branch to checkout
scriptGitCommit (ScriptGitCommit) – Commit object of the commit to checkout
force (bool) – Flag to force checkout
update_flags (VersionUpdateFlags) – Flags for handling project updates
- merge(branchName: str, userName: str, userEmail: str, scriptGitMergeOptions: ScriptGitMergeOptions = None, update_flags: VersionUpdateFlags = VersionUpdateFlags.NoUpdates) tuple[ScriptProject.ScriptProject, ScriptGitMergeResult.ScriptGitMergeResult] ¶
- merge(scriptGitBranch: ScriptGitBranch, userName: str, userEmail: str, scriptGitMergeOptions: ScriptGitMergeOptions = None, update_flags: VersionUpdateFlags = VersionUpdateFlags.NoUpdates) tuple[ScriptProject.ScriptProject, ScriptGitMergeResult.ScriptGitMergeResult]
- Merges the branch with the given name into the current branch.git-merge - Join two or more development histories together
- Parameters:
branchName (str) – Name of the branch to merge into current branch
scriptGitBranch (ScriptGitBranch) – Branch object of the branch to merge into current branch
userName (str) – Username
userEmail (str) – E-mail
scriptGitMergeOptions (ScriptGitMergeOptions) – Merge Options
update_flags (VersionUpdateFlags) – Flags for handling project updates
- reset_mixed_all() None ¶
- Resets the index but not the working tree.git-reset –mixed - Reset current HEAD to the specified state
- discard_all_changes(update_flags: VersionUpdateFlags = VersionUpdateFlags.NoUpdates) ScriptProject ¶
- Discard all changes.Does a git reset –hard and additionally removes all untracked files.
- Parameters:
update_flags (VersionUpdateFlags) – Flags for handling project updates
- path() str ¶
- Gets the path of the working tree.
- has_working_tree() bool ¶
- Checks if the given project handle has a git working tree.
- has_working_object(extendedObject: ScriptObject) bool ¶
- Checks if the given object has a git working tree object (is under version control).
- Parameters:
extendedObject (ScriptObject) – ScriptObject to check for working tree object
- has_uncommitted_changes() bool ¶
- Checks if there are uncommitted changes.
- has_working_tree_changes() bool ¶
- Checks if there are changes in the working tree which are not staged.
- has_index_changes() bool ¶
- Checks if there are changes in the index which are not committed.
- remote() ScriptGitRemoteCollection ¶
- Lookup and enumerate remotes in the repository.git-remote - Manage set of tracked repositories
- remote_add(remoteName: str, sUrlOrDirectoryPath: str) ScriptGitRemote ¶
- Adds a remote with the given name and URL.git remote add <name> <url> - Add a remote named <name> for the repository at <url>.
- Parameters:
remoteName (str) – Name of the remote
sUrlOrDirectoryPath (str) – URL or path of the remote
- remote_remove(remoteName: str) None ¶
- remote_remove(remote: ScriptGitRemote) None
- Removes a remote with the given name.git remote remove <name> - Remove the remote named <name>. All remote-tracking branches and configuration settings for the remote are removed.
- Parameters:
remoteName (str) – Name of the remote to remove
remote (ScriptGitRemote) – Remote object of the remote to remove
- remote_rename(oldRemoteName: str, newRemoteName: str) ScriptGitRemote ¶
- remote_rename(remote: ScriptGitRemote, newRemoteName: str) ScriptGitRemote
- Rename the remote with the given old name to the given new name.git remote rename <old> <new> - Rename the remote named <old> to <new>. All remote-tracking branches and configuration settings for the remote are updated.
- Parameters:
oldRemoteName (str) – Name of the remote to rename
remote (ScriptGitRemote) – Remote object of the remote to rename
newRemoteName (str) – New name of the remote
- remote_set_url(remoteName: str, urlOrDirectoryPath: str) None ¶
- remote_set_url(remote: ScriptGitRemote, urlOrDirectoryPath: str) None
- Change for the given remote the URL.git remote set-url <name> <newurl> - Changes URLs for the remote
- Parameters:
remoteName (str) – Name of the remote to rename
remote (ScriptGitRemote) – Remote object of the remote to rename
urlOrDirectoryPath (str) – New URL or path of the remote
- branch_track(trackedBranchName: str, localBranchName: str = None) None ¶
- branch_track(trackedBranchName: str, localScriptGitBranch: ScriptGitBranch) None
- branch_track(trackedScriptGitBranch: ScriptGitBranch, localBranchName: str = None) None
- branch_track(trackedScriptGitBranch: ScriptGitBranch, localScriptGitBranch: ScriptGitBranch) None
- Let the local branch track a remote branch.Tracking branches are local branches that have a direct relationship to a remote branch.git-branch –track <branchname> [<start-point>] - Track branch
- Parameters:
trackedBranchName (str) – Name of the branch to track
localBranchName (str) – Name of the tracking branch
trackedScriptGitBranch (ScriptGitBranch) – Branch object of the branch to track
localScriptGitBranch (ScriptGitBranch) – Branch object of the tracking branch
- branch_set_upstream_to(remoteName: str, branchName: str = None) None ¶
- branch_set_upstream_to(remoteName: str, scriptGitBranch: ScriptGitBranch) None
- branch_set_upstream_to(remote: ScriptGitRemote, branchName: str = None) None
- branch_set_upstream_to(remote: ScriptGitRemote, scriptGitBranch: ScriptGitBranch) None
- Set up the tracking information of the local branch.git branch –set-upstream-to=<upstream> [<branchname>] - Set up <branchname>’s trackinginformation so <upstream> is considered <branchname>’s upstream branch.
- Parameters:
remoteName (str) – Name of the remote
branchName (str) – Name of the branch
remote (ScriptGitRemote) – Remote object of the remote
scriptGitBranch (ScriptGitBranch) – Branch object of the branch
- branch_unset_upstream(branchName: str = None) None ¶
- branch_unset_upstream(scriptGitBranch: ScriptGitBranch) None
- Remove the tracking information of the local branch.git branch –unset-upstream <branchname> - Remove the upstream information for <branchname>.
- Parameters:
branchName (str) – Name of the branch
scriptGitBranch (ScriptGitBranch) – Branch object of the branch
- fetch(remoteName: str, prune: bool = False) None ¶
- fetch(remoteName: str, username: str, password: str, prune: bool = False) None
- fetch(remoteName: str, username: str, password: SecureString, prune: bool = False) None
- fetch(remote: ScriptGitRemote, prune: bool = False) None
- fetch(remote: ScriptGitRemote, username: str, password: str, prune: bool = False) None
- fetch(remote: ScriptGitRemote, username: str, password: SecureString, prune: bool = False) None
- Fetch from remote.git fetch <remote> - Download objects and refs from another repository
Warning
For passwords use of the SecureString overload is advised for security reasons.
- Parameters:
remoteName (str) – Name of the remote
remote (ScriptGitRemote) – Remote object of the remote
username (str) – Username
password (Union[str,SecureString]) – Password
prune (bool) – Flag for pruning
- pull(userName: str, userEmail: str, scriptGitPullOptions: ScriptGitPullOptions, update_flags: VersionUpdateFlags = VersionUpdateFlags.NoUpdates) tuple[ScriptProject.ScriptProject, ScriptGitMergeResult.ScriptGitMergeResult] ¶
- pull(userName: str, userEmail: str, fetchUsername: str, fetchPassword: str, scriptGitPullOptions: ScriptGitPullOptions, update_flags: VersionUpdateFlags = VersionUpdateFlags.NoUpdates) tuple[ScriptProject.ScriptProject, ScriptGitMergeResult.ScriptGitMergeResult]
- pull(userName: str, userEmail: str, fetchUsername: str, fetchPassword: SecureString, scriptGitPullOptions: ScriptGitPullOptions, update_flags: VersionUpdateFlags = VersionUpdateFlags.NoUpdates) tuple[ScriptProject.ScriptProject, ScriptGitMergeResult.ScriptGitMergeResult]
- Pull changes from remote.git-pull - Fetch from and integrate with another repository or a local branchIncorporates changes from a remote repository into the current branch.In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD.
Warning
For passwords use of the SecureString overload is advised for security reasons.
- Parameters:
userName (str) – Username used for merge commit
userEmail (str) – E-mail used for merge commit
fetchUsername (str) – Username used for fetch
fetchPassword (Union[str,SecureString]) – Password used for fetch
scriptGitPullOptions (ScriptGitPullOptions) – Pull options
update_flags (VersionUpdateFlags) – Flags for handling project updates
- push(branchName: str = None) None ¶
- push(branchName: str, username: str, password: str) None
- push(branchName: str, username: str, password: SecureString) None
- push(scriptGitBranch: ScriptGitBranch) None
- push(scriptGitBranch: ScriptGitBranch, username: str, password: str) None
- push(scriptGitBranch: ScriptGitBranch, username: str, password: SecureString) None
- Push the local change to remote.git-push - Updates remote refs using local refs, while sending objects necessary to complete the given refs.With given RemoteName and RemoteBranchName this can be used as git push –set-upstream <RemoteName> <RemoteBranchName>
Warning
For passwords use of the SecureString overload is advised for security reasons.
- Parameters:
branchName (str) – Name of the branch to push
scriptGitBranch (ScriptGitBranch) – Branch object of the branch to push
username (str) – Username
password (Union[str,SecureString]) – Password
- push_delete(remoteName: str, branchName: str, force: bool = False) None ¶
- push_delete(remote: ScriptGitRemote, branchName: str, force: bool = False) None
- push_delete(remoteName: str, branch: ScriptGitBranch, force: bool = False) None
- push_delete(remote: ScriptGitRemote, branch: ScriptGitBranch, force: bool = False) None
- Deletes a remote branch.git push <remote_name> –delete <branch_name>
- Parameters:
branchName (str) – Name of the branch to delete
remoteName (str) – Name of the remote to push the deletion to
remote (ScriptGitRemote) – Remote object of the remote to push the deletion to
branch (ScriptGitBranch) – Branch object of the branch to delete
force (bool) – Flag for forcing
- get_current_git_operation() CurrentGitOperation ¶
- Gets the current Git operation.
- last_commit() ScriptGitCommit ¶
- Gets the commit the current repository head points to.
- Return type:
- Returns:
The commit the current repository head points to.
- is_last_commit_pushed() bool ¶
- Returns true if the most recent commit in the current branch is already pushed to remote.
- synchronize_project() None ¶
- Synchronizes the CODESYS project to the git project storage.
- resynchronize_project(update_flags: VersionUpdateFlags = VersionUpdateFlags.NoUpdates) ScriptProject ¶
- Enforces resynchronization of the CODESYS project from the content of the CODESYS Git project storage.
- Parameters:
update_flags (VersionUpdateFlags) – Flags for handling project updates
- Return type:
- Returns:
Resulting CODESYS project