fortrangoingonforty/fuss / 7139e59

Browse files

tag functionality with t

Authored by espadonne
SHA
7139e59f8f444e560a8015e10ffad177f688c200
Parents
d7f6cd0
Tree
589d24f

3 changed files

StatusFile+-
M src/display_module.f90 1 1
M src/fuss_main.f90 27 0
M src/git_module.f90 29 0
src/display_module.f90modified
@@ -174,7 +174,7 @@ contains
174174
                      achar(27) // '[31m✗' // achar(27) // '[0m=modified ' // &
175175
                      achar(27) // '[90m✗' // achar(27) // '[0m=untracked ' // &
176176
                      achar(27) // '[34m↓' // achar(27) // '[0m=incoming'
177
-        print '(A)', 'Keys: j/k/↑/↓:nav | a:stage | u:unstage | f:fetch | d:diff | l:pull | m:commit | p:push | s:status | q:quit'
177
+        print '(A)', 'Keys: j/k/↑/↓:nav | a:stage | u:unstage | f:fetch | d:diff | l:pull | m:commit | p:push | t:tag | s:status | q:quit'
178178
 
179179
         call free_tree(root)
180180
     end subroutine draw_interactive_tree
src/fuss_main.f90modified
@@ -219,6 +219,8 @@ contains
219219
                 call mark_incoming_changes(files, n_files)
220220
                 call build_item_list(files, n_files, items, n_items)
221221
                 if (selected > n_items .and. n_items > 0) selected = n_items
222
+            case ('t')  ! Tag (lowercase)
223
+                call tag_prompt()
222224
             case ('f')  ! Git fetch
223225
                 call git_fetch()
224226
                 ! Refresh files after fetch and include files with incoming changes
@@ -407,4 +409,29 @@ contains
407409
         call read_key(key)
408410
     end subroutine push_prompt
409411
 
412
+    subroutine tag_prompt()
413
+        character(len=512) :: tag_name, tag_message
414
+        logical :: success
415
+        character(len=1) :: key
416
+
417
+        ! Clear screen for tag prompt
418
+        call clear_screen()
419
+        print '(A)', achar(27) // '[1mGit Tag' // achar(27) // '[0m'
420
+        print '(A)', ''
421
+
422
+        ! Read tag name
423
+        call read_line('Tag name: ', tag_name)
424
+
425
+        ! Execute tag if name is not empty
426
+        if (len_trim(tag_name) > 0) then
427
+            ! Read tag message (optional)
428
+            call read_line('Tag message (enter for none): ', tag_message)
429
+
430
+            call git_tag(tag_name, tag_message, success)
431
+
432
+            ! Wait for keypress to continue
433
+            call read_key(key)
434
+        end if
435
+    end subroutine tag_prompt
436
+
410437
 end program fuss
src/git_module.f90modified
@@ -698,4 +698,33 @@ contains
698698
         call execute_command_line('stty cbreak -echo < /dev/tty', exitstat=status)
699699
     end subroutine git_diff_file
700700
 
701
+    subroutine git_tag(tag_name, tag_message, success)
702
+        character(len=*), intent(in) :: tag_name
703
+        character(len=*), intent(in) :: tag_message
704
+        logical, intent(out) :: success
705
+        integer :: status
706
+        character(len=2048) :: command
707
+
708
+        success = .false.
709
+
710
+        if (len_trim(tag_message) > 0) then
711
+            ! Create annotated tag with message
712
+            write(command, '(A,A,A,A,A)') 'git tag -a "', trim(tag_name), '" -m "', trim(tag_message), '" 2>&1'
713
+        else
714
+            ! Create lightweight tag (no message)
715
+            write(command, '(A,A,A)') 'git tag "', trim(tag_name), '" 2>&1'
716
+        end if
717
+
718
+        call execute_command_line(trim(command), exitstat=status)
719
+
720
+        if (status == 0) then
721
+            print '(A)', achar(27) // '[32m✓ Tag created: ' // trim(tag_name) // achar(27) // '[0m'
722
+            success = .true.
723
+        else
724
+            print '(A)', achar(27) // '[31m✗ Failed to create tag' // achar(27) // '[0m'
725
+        end if
726
+
727
+        call execute_command_line('sleep 1', exitstat=status)
728
+    end subroutine git_tag
729
+
701730
 end module git_module