Skip to content

Commit 5ea9ef1

Browse files
authored
Merge pull request #23 from twentyTwo/develop
v0.3.4
2 parents db1afa0 + c2e9bd9 commit 5ea9ef1

File tree

6 files changed

+112
-6
lines changed

6 files changed

+112
-6
lines changed

.github/workflows/publish.yml

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,59 @@ on:
99
workflow_dispatch: # Allow manual trigger
1010

1111
jobs:
12+
verify-changes:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
should_publish: ${{ steps.check-changes.outputs.should_publish }}
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0 # Fetch all history for all tags and branches
22+
23+
- name: Get changed files
24+
id: changed-files
25+
run: |
26+
echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | tr '\n' ' ')" >> $GITHUB_OUTPUT
27+
28+
- name: Check version change and file types
29+
id: check-changes
30+
run: |
31+
# Check if package.json version changed
32+
VERSION_CHANGED=$(git diff ${{ github.event.before }} ${{ github.event.after }} package.json | grep '+\s*"version"')
33+
34+
# Get list of changed files
35+
CHANGED_FILES="${{ steps.changed-files.outputs.files }}"
36+
37+
# Check if only documentation files were changed
38+
DOCS_ONLY=true
39+
for file in $CHANGED_FILES; do
40+
if [[ ! $file =~ \.(md|txt|doc|docx)$ ]] && [[ ! $file =~ ^docs/ ]]; then
41+
DOCS_ONLY=false
42+
break
43+
fi
44+
done
45+
46+
# Initialize should_publish as false
47+
echo "should_publish=false" >> $GITHUB_OUTPUT
48+
49+
if [[ "$DOCS_ONLY" == "true" ]]; then
50+
echo "ℹ️ Only documentation files were changed"
51+
echo "should_publish=false" >> $GITHUB_OUTPUT
52+
elif [[ -z "$VERSION_CHANGED" ]]; then
53+
echo "❌ Version in package.json was not updated"
54+
echo "should_publish=false" >> $GITHUB_OUTPUT
55+
else
56+
echo "✅ Version changed and non-documentation files modified"
57+
echo "should_publish=true" >> $GITHUB_OUTPUT
58+
fi
59+
1260
publish:
61+
needs: verify-changes
62+
if: needs.verify-changes.outputs.should_publish == 'true'
1363
runs-on: ubuntu-latest
14-
environment: VSC EXT # Specify the environment where the secret is stored
64+
environment: VSC EXT
1565

1666
steps:
1767
- name: Checkout code
@@ -52,4 +102,4 @@ jobs:
52102
retention-days: 400 # Maximum retention period allowed by GitHub
53103

54104
- name: Publish to Visual Studio Marketplace
55-
run: vsce publish -p "${{ secrets.VSC_PAT }}"
105+
run: vsce publish -p "${{ secrets.VSC_PAT }}"

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ For technical details about development, release process, and internal architect
122122

123123
## Changelog
124124

125+
### [0.3.4] - 2025-04-19
126+
- Handle multi-root workspaces, external files, and virtual files more effectively.
127+
- Added a verify-changes job to check if a version update is required and ensure non-documentation files are modified before publishing. This prevents unnecessary releases.
128+
- Introduced a new workflow to automate the creation of beta and production releases, including attaching .vsix files and setting appropriate release metadata.
129+
- Added a new technical documentation file outlining the development setup, release process, internal architecture, and testing guidelines for the extension.
130+
125131
### [0.3.0] - 2025-04-14
126132
- Added smart activity detection with configurable inactivity timeout
127133
- Enhanced chart interactivity and responsiveness

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "simple-coding-time-tracker",
33
"displayName": "Simple Coding Time Tracker",
44
"description": "Track and visualize your coding time across projects",
5-
"version": "0.3.3",
5+
"version": "0.3.4",
66
"publisher": "noorashuvo",
77
"license": "MIT",
88
"icon": "icon-sctt.png",

src/database.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ export class Database {
1717

1818
constructor(context: vscode.ExtensionContext) {
1919
this.context = context;
20+
// Log the storage URI path
21+
const storagePath = this.context.storageUri?.fsPath;
22+
if (storagePath) {
23+
console.log('Extension Data Storage Path:', storagePath);
24+
//vscode.window.showInformationMessage(`Data is stored at: ${storagePath}`);
25+
}
2026
}
2127

2228
async addEntry(date: Date, project: string, timeSpent: number) {

src/summaryView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ export class SummaryViewProvider implements vscode.WebviewViewProvider {
537537
}
538538
}
539539
};
540-
540+
541541
window.addEventListener('message', event => {
542542
const message = event.data;
543543
if (message.command === 'update') {
@@ -781,7 +781,7 @@ export class SummaryViewProvider implements vscode.WebviewViewProvider {
781781
content.innerHTML = '<p>No results found.</p>';
782782
return;
783783
}
784-
784+
785785
// Calculate data for all charts
786786
let totalTime = 0;
787787
const projectData = {};

src/timeTracker.ts

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,51 @@ export class TimeTracker implements vscode.Disposable {
149149

150150
private getCurrentProject(): string {
151151
const workspaceFolders = vscode.workspace.workspaceFolders;
152-
return workspaceFolders ? workspaceFolders[0].name : 'Unknown Project';
152+
if (!workspaceFolders) {
153+
return 'Unknown Project';
154+
}
155+
156+
// Get the active text editor
157+
const activeEditor = vscode.window.activeTextEditor;
158+
if (!activeEditor) {
159+
return 'No Active File';
160+
}
161+
162+
// Get workspace information
163+
const workspaceName = vscode.workspace.name || 'Default Workspace';
164+
const workspaceFolder = vscode.workspace.getWorkspaceFolder(activeEditor.document.uri);
165+
166+
if (!workspaceFolder) {
167+
// File is outside any workspace folder
168+
return `External/${this.getExternalProjectName(activeEditor.document.uri)}`;
169+
}
170+
171+
// If we're in a multi-root workspace, prefix with workspace name
172+
if (workspaceFolders.length > 1) {
173+
return `${workspaceName}/${workspaceFolder.name}`;
174+
}
175+
176+
return workspaceFolder.name;
177+
}
178+
179+
private getExternalProjectName(uri: vscode.Uri): string {
180+
// Handle different scenarios for external files
181+
if (uri.scheme !== 'file') {
182+
return 'Virtual Files';
183+
}
184+
185+
// Get the parent folder name for external files
186+
const path = uri.fsPath;
187+
const parentFolder = path.split(/[\\/]/);
188+
189+
// Remove empty segments and file name
190+
const folders = parentFolder.filter(Boolean);
191+
if (folders.length >= 2) {
192+
// Return "ParentFolder/CurrentFolder"
193+
return `${folders[folders.length - 2]}/${folders[folders.length - 1]}`;
194+
}
195+
196+
return 'Other';
153197
}
154198

155199
getTodayTotal(): number {

0 commit comments

Comments
 (0)