forked from noodlapp/noodl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Version control commit, View on GitHub (noodlapp#17)
* feat: Version control commit, View on GitHub * fix: MenuDialog allow undefined menu item This makes it a lot easier to create conditional menu items
- Loading branch information
1 parent
13c9277
commit 4e09a70
Showing
4 changed files
with
35 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/noodl-editor/src/editor/src/views/panels/VersionControlPanel/github.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export function convertGitRemoteUrlToRepoUrl(gitRemoteUrl: string): string { | ||
// Remove the .git extension if present | ||
gitRemoteUrl = gitRemoteUrl.replace(/\.git$/, ''); | ||
|
||
// Extract the repository name and owner from the URL | ||
const regex = /^(?:https?:\/\/)?github\.com\/([^/]+)\/([^/]+)$/; | ||
const match = gitRemoteUrl.match(regex); | ||
|
||
if (match) { | ||
const owner = match[1]; | ||
const repo = match[2]; | ||
// Construct the GitHub repository URL | ||
const repoUrl = `https://github.com/${owner}/${repo}`; | ||
return repoUrl; | ||
} else { | ||
throw new Error('Invalid GitHub Git remote URL'); | ||
} | ||
} | ||
|
||
export function convertGitRemoteUrlToCommitUrl(gitRemoteUrl: string, commitSha: string): string { | ||
const githubLink = convertGitRemoteUrlToRepoUrl(gitRemoteUrl); | ||
return `${githubLink}/commit/${commitSha}`; | ||
} |