-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Feature: Added support for pushing Git commits #12633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
b61ca54
Feature: Support for pushing changes
ferrariofilippo 0a69cc7
Tooltips
ferrariofilippo 7812d9e
Update tooltip
ferrariofilippo ff2156e
Merge
ferrariofilippo 44ef185
Handle Login
ferrariofilippo 6042916
Merge branch 'main' into Git_Push
ferrariofilippo 0e09857
Merge leftovers
ferrariofilippo 58cc802
Requested Changes
ferrariofilippo 034f86b
Requested Changes
ferrariofilippo ddb7b5a
Merge branch 'main' into Git_Push
yaira2 dc635a5
Build pipeline
yaira2 81e7b0c
Merge branch 'main' into Git_Push
yaira2 8348eaa
Fix requests
ferrariofilippo e3d90ff
Device Flow not working
ferrariofilippo 0316d2e
Remove " from token
ferrariofilippo d1aa133
Bug Fix & Copy Button
ferrariofilippo cbde437
Copy Button
ferrariofilippo 97189e4
Update Dialog
ferrariofilippo fe50c5d
Merge branch 'main' into Git_Push
ferrariofilippo 900bffe
Update modal
ferrariofilippo 1b4369b
Icons
yaira2 077243c
Update StatusBarControl.xaml
yaira2 2818605
Tweak path
yaira2 e8993a2
Update PathIcons.xaml
yaira2 02dab93
Update PathIcons.xaml
yaira2 e84ed91
Partial Requested Changes
ferrariofilippo efaba3e
Remaining Requested changes
ferrariofilippo 90eb0be
Merge
ferrariofilippo 09af69e
Update PathIcons.xaml
yaira2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,39 @@ | ||
using Files.App.Commands; | ||
using Files.App.Contexts; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal class GitPushAction : ObservableObject, IAction | ||
{ | ||
private readonly IContentPageContext _context; | ||
|
||
public string Label { get; } = "Push".GetLocalizedResource(); | ||
|
||
public string Description { get; } = "GitPushDescription".GetLocalizedResource(); | ||
|
||
public RichGlyph Glyph { get; } = new("\uE74A"); | ||
|
||
public bool IsExecutable => | ||
_context.CanExecuteGitAction; | ||
|
||
public GitPushAction() | ||
{ | ||
_context = Ioc.Default.GetRequiredService<IContentPageContext>(); | ||
|
||
_context.PropertyChanged += Context_PropertyChanged; | ||
} | ||
|
||
public Task ExecuteAsync() | ||
{ | ||
return GitHelpers.PushToOrigin( | ||
_context.ShellPage?.InstanceViewModel.GitRepositoryPath, | ||
_context.ShellPage?.InstanceViewModel.GitBranchName); | ||
} | ||
|
||
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
if (e.PropertyName is nameof(IContentPageContext.CanExecuteGitAction)) | ||
OnPropertyChanged(nameof(IsExecutable)); | ||
} | ||
} | ||
} |
This file contains hidden or 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,42 @@ | ||
using Files.App.Commands; | ||
using Files.App.Contexts; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal class GitSyncAction : ObservableObject, IAction | ||
{ | ||
private readonly IContentPageContext _context; | ||
|
||
public string Label { get; } = "GitSync".GetLocalizedResource(); | ||
|
||
public string Description { get; } = "GitSyncDescription".GetLocalizedResource(); | ||
|
||
public RichGlyph Glyph { get; } = new("\uEDAB"); | ||
|
||
public bool IsExecutable => | ||
_context.CanExecuteGitAction; | ||
|
||
public GitSyncAction() | ||
{ | ||
_context = Ioc.Default.GetRequiredService<IContentPageContext>(); | ||
|
||
_context.PropertyChanged += Context_PropertyChanged; | ||
} | ||
|
||
public Task ExecuteAsync() | ||
{ | ||
var instance = _context.ShellPage?.InstanceViewModel; | ||
|
||
return GitHelpers.PullOrigin(instance?.GitRepositoryPath) | ||
.ContinueWith(t => GitHelpers.PushToOrigin( | ||
instance?.GitRepositoryPath, | ||
instance?.GitBranchName)); | ||
} | ||
|
||
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
if (e.PropertyName is nameof(IContentPageContext.CanExecuteGitAction)) | ||
OnPropertyChanged(nameof(IsExecutable)); | ||
} | ||
} | ||
} |
This file contains hidden or 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 |
---|---|---|
|
@@ -183,5 +183,7 @@ public enum CommandCodes | |
// Git | ||
GitFetch, | ||
GitPull, | ||
GitPush, | ||
GitSync, | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,95 @@ | ||
<!-- Copyright (c) 2023 Files Community. Licensed under the MIT License. See the LICENSE. --> | ||
<ContentDialog | ||
x:Class="Files.App.Dialogs.GitHubLoginDialog" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:converters="using:CommunityToolkit.WinUI.UI.Converters" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:helpers="using:Files.App.Helpers" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
Title="{helpers:ResourceString Name=ConnectGitHub}" | ||
CloseButtonCommand="{x:Bind ViewModel.CloseButtonCommand}" | ||
CloseButtonStyle="{StaticResource AccentButtonStyle}" | ||
CloseButtonText="{helpers:ResourceString Name=Close}" | ||
CornerRadius="{StaticResource OverlayCornerRadius}" | ||
PrimaryButtonClick="ContentDialog_PrimaryButtonClick" | ||
PrimaryButtonText="{helpers:ResourceString Name=OK}" | ||
RequestedTheme="{x:Bind helpers:ThemeHelper.RootTheme}" | ||
Style="{StaticResource DefaultContentDialogStyle}" | ||
mc:Ignorable="d"> | ||
|
||
<ContentDialog.PrimaryButtonStyle> | ||
<Style BasedOn="{StaticResource DefaultButtonStyle}" TargetType="Button"> | ||
<Setter Property="ContentTemplate"> | ||
<Setter.Value> | ||
<DataTemplate> | ||
<StackPanel | ||
HorizontalAlignment="Center" | ||
Orientation="Horizontal" | ||
Spacing="8"> | ||
<FontIcon FontSize="14" Glyph="" /> | ||
<TextBlock Text="{helpers:ResourceString Name=CopyCode}" /> | ||
</StackPanel> | ||
</DataTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
</ContentDialog.PrimaryButtonStyle> | ||
|
||
<ContentDialog.Resources> | ||
<ResourceDictionary> | ||
<converters:BoolNegationConverter x:Key="BoolNegationConverter" /> | ||
</ResourceDictionary> | ||
</ContentDialog.Resources> | ||
|
||
<Grid RowSpacing="20"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition /> | ||
</Grid.RowDefinitions> | ||
|
||
<StackPanel Width="360" Height="40"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you change this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in #12793 |
||
<!-- Subtitle --> | ||
<TextBlock | ||
ferrariofilippo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
x:Name="Subtitle" | ||
Grid.Row="0" | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Center" | ||
Text="{x:Bind ViewModel.Subtitle, Mode=OneWay}" | ||
TextWrapping="WrapWholeWords" /> | ||
</StackPanel> | ||
|
||
<StackPanel | ||
x:Name="UserCodeContainer" | ||
Grid.Row="1" | ||
HorizontalAlignment="Stretch" | ||
VerticalAlignment="Stretch" | ||
x:Load="{x:Bind ViewModel.LoginConfirmed, Converter={StaticResource BoolNegationConverter}, Mode=OneWay}"> | ||
<HyperlinkButton | ||
x:Name="LoginUrl" | ||
Content="{x:Bind ViewModel.LoginUrl}" | ||
NavigateUri="{x:Bind ViewModel.NavigateUri}" /> | ||
<TextBlock | ||
Margin="12,8" | ||
CharacterSpacing="150" | ||
FontFamily="Cascadia Mono,Consolas,Segoe UI Variable" | ||
FontSize="32" | ||
FontWeight="Normal" | ||
Text="{x:Bind ViewModel.UserCode}" /> | ||
</StackPanel> | ||
<Border | ||
x:Name="LoginSuccessBadge" | ||
Grid.Row="1" | ||
Width="70" | ||
Height="70" | ||
Margin="8" | ||
x:Load="{x:Bind ViewModel.LoginConfirmed, Mode=OneWay}" | ||
Background="#6ccb5f" | ||
CornerRadius="35"> | ||
<SymbolIcon | ||
Width="52" | ||
Height="52" | ||
Symbol="Accept" /> | ||
</Border> | ||
</Grid> | ||
</ContentDialog> |
This file contains hidden or 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,49 @@ | ||
// Copyright (c) 2023 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
using Microsoft.UI.Xaml.Controls; | ||
using Windows.ApplicationModel.DataTransfer; | ||
|
||
namespace Files.App.Dialogs | ||
{ | ||
public sealed partial class GitHubLoginDialog : ContentDialog, IDialog<GitHubLoginDialogViewModel> | ||
{ | ||
public GitHubLoginDialogViewModel ViewModel | ||
{ | ||
get => (GitHubLoginDialogViewModel)DataContext; | ||
set | ||
{ | ||
if (ViewModel is not null) | ||
ViewModel.PropertyChanged -= ViewModel_PropertyChanged; | ||
|
||
DataContext = value; | ||
if (value is not null) | ||
value.PropertyChanged += ViewModel_PropertyChanged; | ||
} | ||
} | ||
|
||
public GitHubLoginDialog() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public new async Task<DialogResult> ShowAsync() => (DialogResult)await base.ShowAsync(); | ||
|
||
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) | ||
{ | ||
args.Cancel = true; | ||
|
||
var data = new DataPackage(); | ||
data.SetText(ViewModel.UserCode); | ||
|
||
Clipboard.SetContent(data); | ||
Clipboard.Flush(); | ||
} | ||
|
||
private void ViewModel_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
if (e.PropertyName == nameof(GitHubLoginDialogViewModel.LoginConfirmed) && ViewModel.LoginConfirmed) | ||
PrimaryButtonText = null; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.