Skip to content

Commit

Permalink
Added logic to support .deployignore file
Browse files Browse the repository at this point in the history
Signed-off-by: Seb Julliand <[email protected]>
  • Loading branch information
sebjulliand committed Mar 27, 2024
1 parent ec37969 commit 273f3ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions src/api/local/deployTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import createIgnore, { Ignore } from 'ignore';
import path, { basename } from 'path';
import vscode, { Uri, WorkspaceFolder } from 'vscode';
import { instance } from '../../instantiate';
import { LocalLanguageActions } from './LocalLanguageActions';
import { DeploymentMethod, DeploymentParameters } from '../../typings';
import { ConnectionConfiguration } from '../Configuration';
import { Tools } from '../Tools';
import { LocalLanguageActions } from './LocalLanguageActions';
import { Deployment } from './deployment';

type ServerFileChanges = {uploads: Uri[], relativeRemoteDeletes: string[]};
Expand Down Expand Up @@ -337,13 +336,18 @@ export namespace DeployTools {

export async function getDefaultIgnoreRules(workspaceFolder: vscode.WorkspaceFolder): Promise<Ignore> {
const ignoreRules = createIgnore({ ignorecase: true }).add(`.git`);
// get the .gitignore file from workspace
const gitignores = await vscode.workspace.findFiles(new vscode.RelativePattern(workspaceFolder, `.gitignore`), ``, 1);
if (gitignores.length > 0) {
// get the .deployignore file or .gitignore file from workspace with priority to .deployignore
const ignoreFile = [
...await vscode.workspace.findFiles(new vscode.RelativePattern(workspaceFolder, `.deployignore`), ``, 1),
...await vscode.workspace.findFiles(new vscode.RelativePattern(workspaceFolder, `.gitignore`), ``, 1)
].at(0);

if (ignoreFile) {
// get the content from the file
const gitignoreContent = (await vscode.workspace.fs.readFile(gitignores[0])).toString().replace(new RegExp(`\\\r`, `g`), ``);
const gitignoreContent = (await vscode.workspace.fs.readFile(ignoreFile)).toString().replace(new RegExp(`\\\r`, `g`), ``);
ignoreRules.add(gitignoreContent.split(`\n`));
ignoreRules.add('**/.gitignore');
ignoreRules.add('**/.deployignore');
}

return ignoreRules;
Expand Down
2 changes: 1 addition & 1 deletion src/views/ifsBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { BrowserItem, BrowserItemParameters, FocusOptions, IFSFile, IFS_BROWSER_
const URI_LIST_MIMETYPE = "text/uri-list";
const URI_LIST_SEPARATOR = "\r\n";
const PROTECTED_DIRS = /^(\/|\/QOpenSys|\/QSYS\.LIB|\/QDLS|\/QOPT|\/QNTC|\/QFileSvr\.400|\/bin|\/dev|\/home|\/tmp|\/usr|\/var)$/i;
const ALWAYS_SHOW_FILES = /^(\.gitignore|\.vscode)$/i;
const ALWAYS_SHOW_FILES = /^(\.gitignore|\.vscode|\.deployignore)$/i;
type DragNDropAction = "move" | "copy";
type DragNDropBehavior = DragNDropAction | "ask";
const getDragDropBehavior = () => GlobalConfiguration.get<DragNDropBehavior>(`IfsBrowser.DragAndDropDefaultBehavior`) || "ask";
Expand Down

0 comments on commit 273f3ef

Please sign in to comment.